Parse an xml.dom Node object representing a component group into
        this object.
427740
def parse_xml_node(self, node):
        '''

        '''
        self.group_id = node.getAttributeNS(RTS_NS, 'groupId')
        self._members = []
        for c in node.getElementsByTagNameNS(RTS_NS, 'Members'):
            self._members.append(TargetComponent().parse_xml_node(c))
        return self
193085
def nodeToXML(nodeObject):
    

    xmlRoot = etree.Element(NODE + "node", nsmap=NODE_NSMAP)
    nameNode = etree.SubElement(xmlRoot, NODE + "name")
    nameNode.text = nodeObject.node_name
    urlNode = etree.SubElement(xmlRoot, NODE + "url")
    urlNode.text = nodeObject.node_url
    pathNode = etree.SubElement(xmlRoot, NODE + "path")
    pathNode.text = nodeObject.node_path
    capNode = etree.SubElement(xmlRoot, NODE + "capacity")
    capNode.text = str(nodeObject.node_capacity)
    sizeNode = etree.SubElement(xmlRoot, NODE + "size")
    sizeNode.text = str(nodeObject.node_size)
    if nodeObject.last_checked:
        checkedNode = etree.SubElement(xmlRoot, NODE + "lastChecked")
        checkedNode.text = nodeObject.last_checked.strftime(TIME_FORMAT_STRING)
    return xmlRoot
519660
private static UNode parseXMLElement(Element elem) {
        assert elem != null;
        
        // Get the element's content and attributes, if any.
        String content = Utils.getElementText(elem);
        NamedNodeMap attrMap = elem.getAttributes();
        
        // Map the element's child elements, if any, into a UNode list. This also tells us
        // if there are any child nodes.
        List<UNode> childUNodeList = new ArrayList<UNode>();
        boolean bDupNodeNames = parseXMLChildElems(elem, childUNodeList);
        
        // Decide what the element becomes as documented above.
        UNode result = null;
        
        // Detect base64 encoding attribute and remove it.
        String encoding = elem.getAttribute("encoding");
        if (!Utils.isEmpty(encoding) && encoding.equalsIgnoreCase("base64")) {
            attrMap.removeNamedItem("encoding");
            content = Utils.base64ToString(content);
        }
        
        // Case 1): <key>Stellar1</key>
        if (attrMap.getLength() == 0 && childUNodeList.size() == 0) {
            // No attributes and no child elements. Use the tag name and the element
            // content (which may be empty) as the node value.
            result = createValueNode(elem.getTagName(), content);
        
        // Case 2): <field name="_ID">lollapalooza</field>
        } else if (attrMap.getLength() == 1 &&
                        elem.getAttribute("name").length() > 0 &&
                        childUNodeList.size() == 0) {
            // Only a "name" attribute and no child elements. Use attribute value as the
            // name and content as the value.
            result = createValueNode(elem.getAttribute("name"), content, elem.getTagName());
            
        // Case 3): <option name="AutoTables" value="false"/>
        } else if (attrMap.getLength() == 2 &&
                        elem.getAttribute("name").length() > 0 &&
                        elem.getAttribute("value").length() > 0 &&
                        childUNodeList.size() == 0) {
            // Use values of "name" and "value" attributes. No content allowed.
            assert content.length() == 0 : "Content is not allowed for 'name/value' element: " + content;
            result = createValueNode(elem.getAttribute("name"), elem.getAttribute("value"), elem.getTagName());
            
        // Case 4): All other cases generate a MAP or an ARRAY.
        } else {
            // We shouldn't have any content for these nodes.
            assert content.length() == 0 : "Unexpected content for element '" +
                                           elem.getTagName() + "': " + content;
            
            // Use the "name" attribute value for the UNode name, if present. Otherwise,
            // use the element name.
            if (elem.getAttribute("name").length() > 0) {
                if (bDupNodeNames) {
                    result = createArrayNode(elem.getAttribute("name"), elem.getTagName());
                } else {
                    result = createMapNode(elem.getAttribute("name"), elem.getTagName());
                }
                attrMap.removeNamedItem("name");
            } else {
                if (bDupNodeNames) {
                    result = createArrayNode(elem.getTagName());
                } else {
                    result = createMapNode(elem.getTagName());
                }
            }
            
            // Map remaining attributes, if any, into child UNode objects and add all
            // child UNodes to this node's list.
            parseXMLAttributes(attrMap, childUNodeList);
            result.addChildNodes(childUNodeList);
        }
        return result;
    }
963465
def parse_string(xml):
    
    string = ""
    # Traverse all the <sentence> elements in the XML.
    dom = XML(xml)
    for sentence in dom(XML_SENTENCE):
        _anchors.clear()     # Populated by calling _parse_tokens().
        _attachments.clear() # Populated by calling _parse_tokens().
        # Parse the language from <sentence language="">.
        language = sentence.get(XML_LANGUAGE, "en")
        # Parse the token tag format from <sentence token="">.
        # This information is returned in TokenString.tags,
        # so the format and order of the token tags is retained when exporting/importing as XML.
        format = sentence.get(XML_TOKEN, [WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA])
        format = not isinstance(format, basestring) and format or format.replace(" ","").split(",")
        # Traverse all <chunk> and <chink> elements in the sentence.
        # Find the <word> elements inside and create tokens.
        tokens = []
        for chunk in sentence:
            tokens.extend(_parse_tokens(chunk, format))
        # Attach PNP's to their anchors.
        # Keys in _anchors have linked anchor chunks (each chunk is a list of tokens).
        # The keys correspond to the keys in _attachments, which have linked PNP chunks.
        if ANCHOR in format:
            A, P, a, i = _anchors, _attachments, 1, format.index(ANCHOR)
            for id in sorted(A.keys()):
                for token in A[id]:
                    token[i] += "-"+"-".join(["A"+str(a+p) for p in range(len(P[id]))])
                    token[i]  = token[i].strip("O-")
                for p, pnp in enumerate(P[id]):
                    for token in pnp: 
                        token[i] += "-"+"P"+str(a+p)
                        token[i]  = token[i].strip("O-")
                a += len(P[id])
        # Collapse the tokens to string.
        # Separate multiple sentences with a new line.
        tokens = ["/".join([tag for tag in token]) for token in tokens]
        tokens = " ".join(tokens)
        string += tokens + "\n"
    # Return a TokenString, which is a unicode string that transforms easily
    # into a plain str, a list of tokens, or a Sentence.
    try:
        if MBSP: from mbsp import TokenString
        return TokenString(string.strip(), tags=format, language=language)
    except:
        return TaggedString(string.strip(), tags=format, language=language)
825416
private String parseXmlElement(Element element) {
        if(element.getFirstChild() instanceof Text) {
            Text text = (Text) element.getFirstChild();
            return text.getData();
        }
       
        return toXml(element);
    }
783371
function parse (node, self) {
  let block = false

  if (node.nodeType === 3) {
    let delimiters = self.templateDelimiters

    if (delimiters) {
      let tokens = parseTemplate(node.data, delimiters)

      if (tokens.length) {
        if (!(tokens.length === 1 && tokens[0].type === 0)) {
          tokens.forEach((token, i) => {
            let text = document.createTextNode(token.value)
            node.parentNode.insertBefore(text, node)

            if (token.type === 1) {
              self.buildBinding(TextBinding, text, null, token.value)
            }
          })

          node.parentNode.removeChild(node)
        }
      }
    }
  } else if (node.nodeType === 1) {
    block = self.traverse(node)
  }

  if (!block) {
    Array.prototype.slice.call(node.childNodes).forEach(function (node) { parse(node, self) })
  }
}
447846
def fromxml(node):
        """"""
        if not isinstance(node,ElementTree._Element): #pylint: disable=protected-access
            node = parsexmlstring(node)
        assert node.tag.lower() == 'action'

        kwargs = {}
        args = []
        if 'id' in node.attrib:
            kwargs['id'] = node.attrib['id']
        elif 'name' in node.attrib:
            kwargs['name'] = node.attrib['name']
        elif 'description' in node.attrib:
            kwargs['description'] = node.attrib['description']
        elif 'method' in node.attrib:
            kwargs['method'] = node.attrib['method']
        elif 'mimetype' in node.attrib:
            kwargs['mimetype'] = node.attrib['mimetype']
        elif 'allowanonymous' in node.attrib:
            if node.attrib['allowanonymous'] == "yes":
                kwargs['allowanonymous'] = True

        found = False
        for subnode in node:
            if subnode.tag.lower() == 'parametercondition':
                kwargs[node.tag] = ParameterCondition.fromxml(subnode)
            elif subnode.tag in vars(clam.common.parameters):
                args.append(vars(clam.common.parameters)[subnode.tag].fromxml(subnode))
        if not found:
            raise Exception("No condition found in ParameterCondition!")
        return Action(*args, **kwargs)
859684
def parse(self, root):
        """"""
        #Use the first element in the versions list since there should only be one.
        v = _get_xml_version(root)[0]
        result = {}

        for child in root:         
            if child.tag in self.versions[v].entries:
                entry = self.versions[v].entries[child.tag]
                #Entry can be either a line or a group. Both objects have a parse
                #method that returns a list of values. In the line's case, the
                #list is the values from that line. For the group, it is a list
                #of dictionaries, a dictionary for each tag name.
                result[child.tag] = entry.parse(child)

        return result
490318
@Override
	protected void parse(Node node) {
		NamedNodeMap attributes = node.getAttributes();
		version = getValueRecursive(attributes.getNamedItem("version"));
		tilemapservice = getValueRecursive(attributes.getNamedItem("tilemapservice"));

		NodeList childNodes = node.getChildNodes();
		for (int i = 0; i < childNodes.getLength(); i++) {
			Node child = childNodes.item(i);
			String nodeName = child.getNodeName();
			if ("Title".equalsIgnoreCase(nodeName)) {
				title = getValueRecursive(child);
			} else if ("Abstract".equalsIgnoreCase(nodeName)) {
				abstractt = getValueRecursive(child);
			} else if ("SRS".equalsIgnoreCase(nodeName)) {
				srs = getValueRecursive(child);
			} else if ("BoundingBox".equalsIgnoreCase(nodeName)) {
				boundingBox = getBoundingBox(child);
			} else if ("Origin".equalsIgnoreCase(nodeName)) {
				origin = getCoordinate(child);
			} else if ("TileFormat".equalsIgnoreCase(nodeName)) {
				tileFormat = new TileFormatInfo100(child);
			} else if ("TileSets".equalsIgnoreCase(nodeName)) {
				addTileSets(child);
			}
		}
		if (title == null) {
			throw new IllegalArgumentException("Cannot parse XML into a TileMapInfo object.");
		}
		setParsed(true);
	}
631752
def _parse_node(graph, text, condition_node_params, leaf_node_params):
    """"""
    match = _NODEPAT.match(text)
    if match is not None:
        node = match.group(1)
        graph.node(node, label=match.group(2), **condition_node_params)
        return node
    match = _LEAFPAT.match(text)
    if match is not None:
        node = match.group(1)
        graph.node(node, label=match.group(2), **leaf_node_params)
        return node
    raise ValueError('Unable to parse node: {0}'.format(text))
147565
function parse(xml) {
    var doc;
    if (typeof xml === 'string') {
        var parser = new DOMParser();
        doc = parser.parseFromString(xml, 'text/xml');
    }
    else {
        doc = xml;
    }
    if (!doc || doc.getElementsByTagName('parsererror').length) {
        return null;
    }

    var gexfRoot = getChildByTagName(doc, 'gexf');

    if (!gexfRoot) {
        return null;
    }

    var graphRoot = getChildByTagName(gexfRoot, 'graph');

    var attributes = parseAttributes(getChildByTagName(graphRoot, 'attributes'));
    var attributesMap = {};
    for (var i = 0; i < attributes.length; i++) {
        attributesMap[attributes[i].id] = attributes[i];
    }

    return {
        nodes: parseNodes(getChildByTagName(graphRoot, 'nodes'), attributesMap),
        links: parseEdges(getChildByTagName(graphRoot, 'edges'))
    };
}
219245
def parse_xml_node(self, node):
        '''

        '''
        super(Preceding, self).parse_xml_node(node)
        p_nodes = node.getElementsByTagNameNS(RTS_NS, 'Preceding')
        if p_nodes.length != 1:
            raise InvalidParticipantNodeError
        p_node = p_nodes[0]
        if p_node.hasAttributeNS(RTS_NS, 'timeout'):
            self.timeout = int(p_node.getAttributeNS(RTS_NS, 'timeout'))
        else:
            self.timeout = 0
        if p_node.hasAttributeNS(RTS_NS, 'sendingTiming'):
            self.sending_timing = p_node.getAttributeNS(RTS_NS, 'sendingTiming')
        else:
            self.sending_timing = 'ASYNC'
        self._preceding_components = []
        for c in p_node.getElementsByTagNameNS(RTS_NS, 'PrecedingComponents'):
            self._preceding_components.append(TargetExecutionContext().parse_xml_node(c))
        return self
95326
function parsePlistXML (node) {
  var i, new_obj, key, val, new_arr, res, d;

  if (!node)
    return null;

  if (node.nodeName === 'plist') {
    new_arr = [];
    for (i=0; i < node.childNodes.length; i++) {
      // ignore comment nodes (text)
      if (!shouldIgnoreNode(node.childNodes[i])) {
        new_arr.push( parsePlistXML(node.childNodes[i]));
      }
    }
    return new_arr;

  } else if (node.nodeName === 'dict') {
    new_obj = {};
    key = null;
    for (i=0; i < node.childNodes.length; i++) {
      // ignore comment nodes (text)
      if (!shouldIgnoreNode(node.childNodes[i])) {
        if (key === null) {
          key = parsePlistXML(node.childNodes[i]);
        } else {
          new_obj[key] = parsePlistXML(node.childNodes[i]);
          key = null;
        }
      }
    }
    return new_obj;

  } else if (node.nodeName === 'array') {
    new_arr = [];
    for (i=0; i < node.childNodes.length; i++) {
      // ignore comment nodes (text)
      if (!shouldIgnoreNode(node.childNodes[i])) {
        res = parsePlistXML(node.childNodes[i]);
        if (null != res) new_arr.push(res);
      }
    }
    return new_arr;

  } else if (node.nodeName === '#text') {
    // TODO: what should we do with text types? (CDATA sections)

  } else if (node.nodeName === 'key') {
    return node.childNodes[0].nodeValue;

  } else if (node.nodeName === 'string') {
    res = '';
    for (d=0; d < node.childNodes.length; d++) {
      res += node.childNodes[d].nodeValue;
    }
    return res;

  } else if (node.nodeName === 'integer') {
    // parse as base 10 integer
    return parseInt(node.childNodes[0].nodeValue, 10);

  } else if (node.nodeName === 'real') {
    res = '';
    for (d=0; d < node.childNodes.length; d++) {
      if (node.childNodes[d].nodeType === 3) {
        res += node.childNodes[d].nodeValue;
      }
    }
    return parseFloat(res);

  } else if (node.nodeName === 'data') {
    res = '';
    for (d=0; d < node.childNodes.length; d++) {
      if (node.childNodes[d].nodeType === 3) {
        res += node.childNodes[d].nodeValue.replace(/\s+/g, '');
      }
    }

    // decode base64 data to a Buffer instance
    return new Buffer(res, 'base64');

  } else if (node.nodeName === 'date') {
    return new Date(node.childNodes[0].nodeValue);

  } else if (node.nodeName === 'true') {
    return true;

  } else if (node.nodeName === 'false') {
    return false;
  }
}
348399
def Element(cls, s, *args):
        """"""
        sargs = []
        for arg in args:
            if type(arg) == etree._Element:
                sargs.append(etree.tounicode(arg))
            else:
                sargs.append(arg)
        if type(s) == etree._Element:
            t = etree.tounicode(s)
        else:
            t = s
        if len(args) == 0:
            return XML.fromstring(t)
        else:
            return XML.fromstring(t % tuple(sargs))
1314915
def parse(cls, dom):
        """"""
        handler = cls()
        saxify(dom, handler)
        return handler.content
1224809
def parse_xml_node(self, node):
        '''

        '''
        self.connector_id = node.getAttributeNS(RTS_NS, 'connectorId')
        self.name = node.getAttributeNS(RTS_NS, 'name')
        self.data_type = node.getAttributeNS(RTS_NS, 'dataType')
        self.interface_type = node.getAttributeNS(RTS_NS, 'interfaceType')
        self.data_flow_type = node.getAttributeNS(RTS_NS, 'dataflowType')
        if node.hasAttributeNS(RTS_NS, 'subscriptionType'):
            self.subscription_type = node.getAttributeNS(RTS_NS,
                                                         'subscriptionType')
        else:
            self.subscription_type = ''
        if node.hasAttributeNS(RTS_NS, 'pushInterval'):
            self.push_interval = float(node.getAttributeNS(RTS_NS,
                                                           'pushInterval'))
        else:
            self.push_interval = 0.0
        self.comment = node.getAttributeNS(RTS_EXT_NS, 'comment')
        if node.hasAttributeNS(RTS_EXT_NS, 'visible'):
            visible = node.getAttributeNS(RTS_EXT_NS, 'visible')
            if visible == 'true' or visible == '1':
                self.visible = True
            else:
                self.visible = False

        if node.getElementsByTagNameNS(RTS_NS, 'sourceDataPort').length != 1:
            raise InvalidDataPortConnectorNodeError
        self.source_data_port = TargetPort().parse_xml_node(\
                node.getElementsByTagNameNS(RTS_NS, 'sourceDataPort')[0])
        if node.getElementsByTagNameNS(RTS_NS, 'targetDataPort').length != 1:
            raise InvalidDataPortConnectorNodeError
        self.target_data_port = TargetPort().parse_xml_node(\
                node.getElementsByTagNameNS(RTS_NS, 'targetDataPort')[0])
        for c in get_direct_child_elements_xml(node, prefix=RTS_EXT_NS,
                                               local_name='Properties'):
            name, value = parse_properties_xml(c)
            self._properties[name] = value
        return self
953855
def from_xml(self, doc):
        """"""
        import xml.sax
        handler = DomainDumpParser(self)
        xml.sax.parse(doc, handler)
        return handler