Extracts the values from the specified XML element that is being converted.
192798
def parse(self, element):
        """"""
        #All the children of this element are what we are trying to parse.
        result = []
        for child in element:
            if child.tag in self.lines:
                values = { child.tag: self.lines[child.tag].parse(child) }
                result.append(values)

        return result
928167
def parse_xml(data, handle_units):
    """"""
    root = ET.fromstring(data)
    return squish(parse_xml_dataset(root, handle_units))
559544
def _parse_value(self, el):
        """"""
        if el.find(RDF_NS + 'Bag') is not None:
            value = []
            for li in el.findall(RDF_NS + 'Bag/' + RDF_NS + 'li'):
                value.append(li.text)
        elif el.find(RDF_NS + 'Seq') is not None:
            value = []
            for li in el.findall(RDF_NS + 'Seq/' + RDF_NS + 'li'):
                value.append(li.text)
        elif el.find(RDF_NS + 'Alt') is not None:
            value = {}
            for li in el.findall(RDF_NS + 'Alt/' + RDF_NS + 'li'):
                value[li.get(XML_NS + 'lang')] = li.text
        else:
            value = el.text
        return value
811318
private String getElementValue(Element parent, String elementName) {
        String value = null;
        NodeList nodes = parent.getElementsByTagName(elementName);
        if (nodes.getLength() > 0) {
            value = nodes.item(0).getChildNodes().item(0).getNodeValue();
        }
        return value;
    }
893423
def decodeXML( text )
      encodingStrings( true ) { |key,value| text.gsub!( value, key ) if text }
      text.gsub!( /&#([0-9]{2,3});/ ) { |c| $1.chr } if text
      text
   end
1243948
def to_xml(self, root):
        '''
        
        '''
        if not len(self.__custom_elements):
            return

        for uri, tags in self.__custom_elements.items():
            prefix, url = uri.split(":", 1)
            for name, value in tags.items():
                self.__createElementNS(root, url, prefix + ":" + name, value)

        return root
45502
private void extractNodes() {
        Node n = domDocument.getFirstChild();
        while (n.getChildNodes().getLength() == 0) {
        	n = n.getNextSibling();
        }
        n = n.getFirstChild();
        while (n != null) {
            if (n.getNodeType() == Node.ELEMENT_NODE) {
                String s = n.getLocalName();
                if (s.equals("template")) {
                	templateNode = n;
                    templateSom = new Xml2SomTemplate(n);
                }
                else if (s.equals("datasets")) {
                    datasetsNode = n;
                    datasetsSom = new Xml2SomDatasets(n.getFirstChild());
                }
            }
            n = n.getNextSibling();
        }
    }
159530
public static List<XMLEvent> parse(String theValue) {
		if (isBlank(theValue)) {
			return Collections.emptyList();
		}

		String val = theValue.trim();
		if (!val.startsWith("<")) {
			val = XhtmlDt.DIV_OPEN_FIRST + val + "</div>";
		}
		boolean hasProcessingInstruction = val.startsWith("<?");
		if (hasProcessingInstruction && val.endsWith("?>")) {
			return null;
		}


		try {
			ArrayList<XMLEvent> value = new ArrayList<>();
			StringReader reader = new StringReader(val);
			XMLEventReader er = XmlUtil.createXmlReader(reader);
			boolean first = true;
			while (er.hasNext()) {
				XMLEvent next = er.nextEvent();
				if (first) {
					first = false;
					continue;
				}
				if (er.hasNext()) {
					// don't add the last event
					value.add(next);
				}
			}
			return value;

		} catch (XMLStreamException e) {
			throw new DataFormatException("String does not appear to be valid XML/XHTML (error is \"" + e.getMessage() + "\"): " + theValue, e);
		} catch (FactoryConfigurationError e) {
			throw new ConfigurationException(e);
		}
	}
220080
function (xmlNode) {

            var rawValues = this.getRawValues(xmlNode);
            if (!rawValues) {
                return null;
            }

            var len = rawValues.length;

            var bufferData = new Uint32Array(len);
            for (var i = 0; i < len; i++) {
                bufferData[i] = parseInt(rawValues[i]);
            }

            return bufferData;
        }
714607
def from_xml_node(xml_node):
        

        def gather_enum_values():
            l = []
            for element in xml_node.iterfind('element'):
                l.append(element.text)
            return l

        name = xml_node.findtext("name")
        type = xml_node.tag

        if type in ("label", "description"): return None

        default = xml_node.findtext("default")

        longflag = xml_node.findtext('longflag')

        if default:
            default = default.replace('"', '').replace("'", '')

        index = xml_node.findtext('index')

        label = xml_node.findtext('label') or name or longflag

        doc = xml_node.findtext('description')

        values = gather_enum_values()

        channel = xml_node.findtext('channel')

        file_ext = xml_node.attrib.get('fileExtensions', None)

        return Parameter(name, type, default, doc, channel, values=values, index=index, label=label,
                         longflag=longflag, file_ext=file_ext)
766924
def parse_xml(self, xml):
        '''
            
        '''
        xmlutils = XmlUtils(xml)
        self.code_value = xmlutils.get_string_by_xpath('code-value')
        self.display_text = xmlutils.get_string_by_xpath('display-text')
        self.abbreviation_text = xmlutils.get_string_by_xpath('abbreviation-text')
        info_xml = xml.xpath('info-xml')
        if info_xml != []:
            self.info_xml = info_xml[0]
1100566
def fromxml(node):
        """"""
        if not isinstance(node,ElementTree._Element): #pylint: disable=protected-access
            node = parsexmlstring(node)
        assert node.tag.lower() == 'parametercondition'

        kwargs = {}

        found = False
        for node in node:
            if node.tag == 'if':
                #interpret conditions:
                for subnode in node:
                    operator = subnode.tag
                    parameter = subnode.attrib['parameter']
                    value = subnode.text
                    kwargs[parameter + '_' + operator] = value
                    found = True
            elif node.tag == 'then' or node.tag == 'else' or node.tag == 'otherwise':
                #interpret statements:
                for subnode in node: #MAYBE TODO LATER: Support for multiple statement in then=, else= ?
                    if subnode.tag.lower() == 'parametercondition':
                        kwargs[node.tag] = ParameterCondition.fromxml(subnode)
                    elif subnode.tag == 'meta':
                        #assume metafield?
                        kwargs[node.tag] = AbstractMetaField.fromxml(subnode)
                    elif subnode.tag.lower() == 'outputtemplate':
                        kwargs[node.tag] = OutputTemplate.fromxml(subnode)
        if not found:
            raise Exception("No condition found in ParameterCondition!")
        return ParameterCondition(**kwargs)
226042
def fromxml(node):
        """"""
        if not isinstance(node,ElementTree._Element): #pylint: disable=protected-access
            node = ElementTree.parse(StringIO(node)).getroot()
        if node.tag in globals():
            id = ''
            paramflag = ''
            name = ''
            description = ''
            kwargs = {}
            error = None
            for attrib, value in node.attrib.items():
                if attrib == 'id':
                    id = value
                elif attrib == 'paramflag':
                    paramflag = value
                elif attrib == 'name':
                    name = value
                elif attrib == 'description':
                    description = value
                elif attrib == 'error':
                    error = value
                else:
                    kwargs[attrib] = value

            #extra parsing for choice parameter (TODO: put in a better spot)
            if 'multi' in kwargs and (kwargs['multi'] == 'yes' or kwargs['multi'] == '1' or kwargs['multi'] == 'true'):
                kwargs['value'] = []

            for subtag in node: #parse possible subtags
                if subtag.tag == 'choice': #extra parsing for choice parameter (TODO: put in a better spot)
                    if 'choices' not in kwargs: kwargs['choices'] = {}
                    kwargs['choices'][subtag.attrib['id']] = subtag.text
                    if 'selected' in subtag.attrib and (subtag.attrib['selected'] == '1' or subtag.attrib['selected'] == 'yes'):
                        if 'multi' in kwargs and (kwargs['multi'] == 'yes' or kwargs['multi'] == '1' or kwargs['multi'] == 'true'):
                            kwargs['value'].append(subtag.attrib['id'])
                        else:
                            kwargs['value'] = subtag.attrib['id']

            parameter = globals()[node.tag](id, name, description, **kwargs) #return parameter instance
            if error:
                parameter.error = error #prevent error from getting reset
            return parameter
        else:
            raise Exception("No such parameter exists: " + node.tag)
329369
def raw_xml(self) -> _RawXML:
        
        if self._xml:
            return self._xml
        else:
            return etree.tostring(self.element, encoding='unicode').strip().encode(self.encoding)
590025
def XML(uri, tc, ps, **keywords):
    '''
    '''
    source = urllib.urlopen(uri, **keywords)
    enc = source.info().getencoding()
    if enc in ['7bit', '8bit', 'binary']:
        data = source
    else:
        data = StringIO.StringIO()
        mimetools.decode(source, data, enc)
        data.seek(0)
    dom = ps.readerclass().fromStream(data)
    return _child_elements(dom)[0]
199127
def xmltreefromstring(s):
    """"""
    if sys.version < '3':
        #Python 2
        if isinstance(s,unicode): #pylint: disable=undefined-variable
            s = s.encode('utf-8')
        try:
            return ElementTree.parse(StringIO(s), ElementTree.XMLParser(collect_ids=False))
        except TypeError:
            return ElementTree.parse(StringIO(s), ElementTree.XMLParser()) #older lxml, may leak!!!!
    else:
        #Python 3
        if isinstance(s,str):
            s = s.encode('utf-8')
        try:
            return ElementTree.parse(BytesIO(s), ElementTree.XMLParser(collect_ids=False))
        except TypeError:
            return ElementTree.parse(BytesIO(s), ElementTree.XMLParser())
1168850
def extract_month_from_xml_element(element)
      month = element.xpath('date/month').text.to_i
      year = element.xpath('date/year').text.to_i
      [year, month]
    end