parse an element
353028
private static Type doParse(String str) throws Exception {
        Class<?> token = PRIMITIVES.get(str);
        if (token != null) {
            return token;
        }
        int first = str.indexOf('<');
        if (first < 0) {
            return StringConvert.loadType(str);
        }
        int last = str.lastIndexOf('>');
        String baseStr = str.substring(0, first);
        Class<?> base = StringConvert.loadType(baseStr);
        String argsStr = str.substring(first + 1, last);
        List<String> splitArgs = split(argsStr);
        List<Type> types = new ArrayList<Type>();
        for (String splitArg : splitArgs) {
            Type argType;
            if (splitArg.startsWith(EXTENDS)) {
                String remainder = splitArg.substring(EXTENDS.length());
                argType = wildExtendsType(doParse(remainder));
            } else if (splitArg.startsWith(SUPER)) {
                String remainder = splitArg.substring(SUPER.length());
                argType = wildSuperType(doParse(remainder));
            } else if (splitArg.equals("?")) {
                argType = wildExtendsType(Object.class);
            } else if (splitArg.endsWith("[]")) {
                String componentStr = splitArg.substring(0, splitArg.length() - 2);
                Class<?> componentCls = StringConvert.loadType(componentStr);
                argType = Array.newInstance(componentCls, 0).getClass();
            } else if (splitArg.startsWith("[L") && splitArg.endsWith(";")) {
                String componentStr = splitArg.substring(2, splitArg.length() - 1);
                Class<?> componentCls = StringConvert.loadType(componentStr);
                argType = Array.newInstance(componentCls, 0).getClass();
            } else {
                argType = doParse(splitArg);
            }
            types.add(argType);
        }
        return newParameterizedType(base, types.toArray(new Type[types.size()]));
    }
468154
function parse() {
  var self = this;
  var xml = new expat.Parser('utf-8');
  this._parser = xml;
  this._suspended = false;
  var stack = [];
  var trace = {};
  var curr = {
    element: {},
    collect: this._collect,
    fullText: '',
    space: 0,
    path: '',
    context: {}
  };
  var fa = this._fa;
  fa.setState(this._startState);

  // A listener is assigned on opening tag encounter.
  // Here we traverse the configured finite automata use the stack
  // to form the context and trace for selector event emission.
  xml.on('startElement', function(name, attr) {
    self.emit('startElement', name, attr);
    stack.push(curr);
    trace[curr.path] = curr.element;
    var context = Object.create(curr.context);
    var element = {
      $: attr,
      $name: name,
      $text: ''
    };
    var parent = curr.element;
    curr = {
      element: element,
      collect: false,
      fullText: '',
      space: 0,
      path: curr.path + '/' + name,
      context: context
    };
    self._collect = false;
    fa.enter(name, [element, context, trace]);
    if (self._preserveLevel > 0) {
      element.$children = [];
    }
    name = element.$name;
    curr.collect = self._collect;
    if (curr.collect) {
      var container;
      if (__own.call(parent, name)) {
        container = parent[name];
        container.push(element);
      } else {
        container = [element];
        parent[name] = container;
      }
    } else {
      parent[name] = element;
      context[name] = element;
    }
    if (self._bufferLevel === 0 && self._emitData) {
      emitStart.call(self, name, element.$);
    }
  });

  // A listener is assigned on closing tag encounter.
  // Current node structure object is finalized. A selector listener is
  // invoked with current node, context, and trace; these arguments are
  // removed from the stack afterwards.
  xml.on('endElement', function(name) {
    self.emit('endElement', name);
    var prev = stack.pop();
    var element = curr.element;
    var text = curr.fullText;
    var attr = element.$;
    if (typeof attr !== 'object') {
      attr = {};
    }
    var name = element.$name;
    self._name = name;
    delete element.$;
    delete element.$text;
    delete element.$name;
    var val = element;
    if (isEmpty(element) && isEmpty(attr)) {
      val = text;
    } else if (!isEmpty(attr)) {
      element.$ = attr;
    }
    if (text !== '') {
      element.$text = text;
    }
    if (self._bufferLevel > 0 || self._preserveLevel > 0) {
      element.$name = name;
    }
    curr.context[name] = val;
    if (curr.collect) {
      var container = prev.element[name];
      container[container.length - 1] = val;
    } else {
      prev.element[name] = val;
    }
    fa.leave([element, curr.context, trace]);
    if (self._preserveLevel > 0) {
      prev.element.$children.push(val);
    }
    if (self._bufferLevel === 0 && self._emitData) {
      emitEnd.call(self, name);
    }
    curr = prev;
    this._collect = curr.collect;
  });

  // Collect node text part by part
  // (and trim leading and trailing whitespace).
  xml.on('text', function(text) {
    curr.element.$text = text;
    fa.run('state', [curr.element, curr.context, trace]);
    if (self._bufferLevel === 0 && self._emitData) {
      emitText.call(self, text);
    }
    if (!self._preserveAll) {
        var trimmed = curr.element.$text.trim();
        var spaced = curr.element.$text.substr(0, 1);
        spaced = (spaced !== '') && (spaced.trim() === '');
        var after = curr.element.$text.substr(-1, 1);
        after = (after !== '') && (after.trim() === '');
        switch (curr.space) {
          // No words yet (pass through spaces).
          case 0:
            if (trimmed !== '') {
              curr.space = after ? 2 : 1;
            }
            break;

          // Immediately after text or entity.
          case 1:
            if (trimmed === '') {
              curr.space = 2;
            } else {
              if (spaced) {
                curr.fullText += ' ';
              }
              if (after) {
                curr.space = 2;
              }
            }
            break;

          // Some words were emitted, pass through spaces again.
          // Emit spaces only when a word is encountered afterwards.
          case 2:
            if (trimmed !== '') {
              curr.fullText += ' ';
              curr.space = 1;
            }
            break;
        }
        text = self._preserveWhitespace > 0 ? text : trimmed;
        if (self._preserveLevel > 0) {
          if (text !== '') {
            curr.element.$children.push(text);
          }
        }
    }
    curr.fullText += text;
  });


  // This prelude array and string are used during encoding detection.
  // Incoming buffers are collected and parsing is postponed,
  // but only until the first tag.
  var prelude = '';
  var preludeBuffers = [];

  // Parse incoming chunk.
  // Convert to UTF-8 or emit errors when appropriate.
  var parseChunk = function(data) {
    if (self._encoder) {
      data = self._encoder.convert(data);
    }
    if (!xml.parse(data, false)) {
      self.emit('error', new Error(xml.getError()+" in line "+xml.getCurrentLineNumber()));
    }
  }

  // Pass data from stream to parser.
  this._stream.on('data', function(data) {
    if (self._encoding) {
      parseChunk(data);
    } else {
      // We can't parse when the encoding is unknown, so we'll look into
      // the XML declaration, if there is one. For this, we need to buffer
      // incoming data until a full tag is received.
      preludeBuffers.push(data);
      prelude += data.toString();
      if (/^\s*<[^>]+>/.test(prelude)) {
        var matches = prelude.match(/^\s*<\?xml[^>]+encoding="(.+?)"[^>]*\?>/);
        self._encoding = matches ? matches[1] : 'utf8';
        self._encoder = makeEncoder(self._encoding);
        for (var i = 0, n = preludeBuffers.length; i < n; i++) {
          parseChunk(preludeBuffers[i]);
        }
      }
    }
  });

  // End parsing on stream EOF and emit an *end* event ourselves.
  this._stream.on('end', function() {
    if (!xml.parse('', true)) {
      self.emit('error', new Error(xml.getError()+" in line "+xml.getCurrentLineNumber()));
    }
    self.emit('end');
  });
}
1153359
private LayoutElement parseElement(Element node, LayoutElement parent) {
        LayoutElement layoutElement = newLayoutElement(node, parent, null);
        parseChildren(node, layoutElement, Tag.ELEMENT, Tag.TRIGGER);
        return layoutElement;
    }
244939
def parse_elem(element):
        
        ident = int(element.get('id'))
        latitude = element.get('lat')
        longitude = element.get('lon')

        flags = _parse_flags(element)

        return Node(ident, latitude, longitude, *flags)
23494
def _parse_text(self, el, refs=None, specials=None,  element_cls=Paragraph):
        """"""
        if specials is None:
            specials = {}
        if refs is None:
            refs = {}
        elements = self._parse_element_r(el, specials=specials, refs=refs, element_cls=element_cls)
        # This occurs if the input element is self-closing... (some table td in NLM XML)
        if not elements:
            return [element_cls('')]
        element = elements[0]
        for next_element in elements[1:]:
            element += element_cls(' ') + next_element
        return [element]
651242
function parse(str, options = {}) {
    let tokens = tokenize(str)
    let data = []

    tokens.forEach((item, idx) => {
        let [ label, token ] = item
        if (renderRules[label]) {
            data.push(renderRules[label](token))
        }else {
            data.push([ RENDER_TYPE_PLAIN, token ])
        }
    })
    return data
}
120046
def parse_at_element(
            self,
            element,  # type: ET.Element
            state  # type: _ProcessorState
    ):
        # type: (...) -> Any
        """"""
        parsed_dict = {}

        for child in self._child_processors:
            state.push_location(child.element_path)
            parsed_dict[child.alias] = child.parse_from_parent(element, state)
            state.pop_location()

        return parsed_dict
1083131
def parse_Element(self, node):
        
        name = node.tagName
        ignores = self.ignores
        if name in ignores:
            return
        attr = "do_%s" % name
        if hasattr(self, attr):
            handlerMethod = getattr(self, attr)
            handlerMethod(node)
        else:
            self.generic_parse(node)
224545
def get_element(parent_to_parse, element_path=None):
    

    if parent_to_parse is None:
        return None

    elif isinstance(parent_to_parse, ElementTree):
        parent_to_parse = parent_to_parse.getroot()

    elif hasattr(parent_to_parse, 'read'):
        parent_to_parse = string_to_element(parent_to_parse.read())

    elif isinstance(parent_to_parse, STRING_TYPES):
        parent_to_parse = string_to_element(parent_to_parse)

    elif isinstance(parent_to_parse, dict):
        parent_to_parse = dict_to_element(parent_to_parse)

    if parent_to_parse is None:
        return None
    elif not isinstance(parent_to_parse, ElementType):
        element_type = type(parent_to_parse).__name__
        raise TypeError('Invalid element type: {0}'.format(element_type))

    return parent_to_parse.find(element_path) if element_path else parent_to_parse
384054
private Object parseXmlElement(Element element) {
        if(element.getFirstChild() instanceof Text) {
            Text text = (Text) element.getFirstChild();
            return text.getData();
        }
        return element;
    }
259462
def _parse_string_el(el):
    """"""
    value = str(el)
    el_type = el.attributes().get('xsi:type')
    if el_type and el_type.value == 'xsd:base64Binary':
        value = base64.b64decode(value)
        if not PY2:
            value = value.decode('utf-8', errors='replace')
    value = _uc(value)
    return value
797014
def parse(source, remove_comments=True, **kw):
    """"""
    return ElementTree.parse(source, SourceLineParser(), **kw)
62941
function parseObject(tag, attrs, content, indentStr, indentLevel) {
    if (TEXT in content) {
        let args = [tag, attrs, content[TEXT], indentStr, indentLevel];
        return getType(content[TEXT])==='array' ? parseArray.apply(this, args) : renderElement.apply(this, args);
    } else {
        content = isNested(content) ? content : '';
        return renderElement(tag, attrs, content, indentStr, indentLevel);
    }
}
1326822
def parse_full(self, element):
        
        """
        values = collections.defaultdict(dict)
        for child in element:
            node = self.get_node(child)
            subs = self.parse_full(child)
            value = subs or {'values': node['value']}
            value['attrs'] = node['attr']
            if node['tag'] not in values['values']:
                values['values'][node['tag']] = value
            else:
                if not isinstance(values['values'][node['tag']], list):
                    values['values'][node['tag']] = [values['values'].pop(node['tag'])]
                values['values'][node['tag']].append(value)
        return values
1219943
def _parse(self):
        
        for child in self._element:
            method_name = '_parse_{0}'.format(str(child.tag))  # TODO: This is a hack, skip comment objects here

            if hasattr(self, method_name):
                parse = getattr(self, method_name)
                parse(child)
700610
private void parse()
    {
        this.elements = new ArrayList<>();

        try {
            for (Tokenizer tokenizer = new Tokenizer(this.rawVersion); tokenizer.next();) {
                Element element = new Element(tokenizer);
                this.elements.add(element);
                if (element.getVersionType() != Type.STABLE) {
                    this.type = element.getVersionType();
                }
            }

            trimPadding(this.elements);
        } catch (Exception e) {
            // Make sure to never fail no matter what
            LOGGER.error("Failed to parse version [" + this.rawVersion + "]", e);
            this.elements.add(new Element(this.rawVersion));
        }
    }
655270
function parseStyleAttribute(element) {
    var oStyle = { },
        style = element.getAttribute('style');
    if (style) {
      if (typeof style == 'string') {
        style = style.replace(/;$/, '').split(';').forEach(function (current) {
            var attr = current.split(':');
            oStyle[normalizeAttr(attr[0].trim().toLowerCase())] = attr[1].trim();
        });
      } else {
        for (var prop in style) {
          if (typeof style[prop] !== 'undefined') {
            oStyle[normalizeAttr(prop.toLowerCase())] = style[prop];
          }
        }
      }
    }
    return oStyle;
  }