Parse the xml file to create types, scaling factor types, and scales.
778437
def parse_format(xml_file):
    
    tree = ElementTree()
    tree.parse(xml_file)

    for param in tree.find("parameters").getchildren():
        VARIABLES[param.get("name")] = param.get("value")

    types_scales = {}

    for prod in tree.find("product"):
        ascii = (prod.tag in ["mphr", "sphr"])
        res = []
        for i in prod:
            lres = CASES[i.tag](i, ascii)
            if lres is not None:
                res.append(lres)
        types_scales[(prod.tag, int(prod.get("subclass")))] = res

    types = {}
    stypes = {}
    scales = {}

    for key, val in types_scales.items():
        types[key] = to_dtype(val)
        stypes[key] = to_scaled_dtype(val)
        scales[key] = to_scales(val)

    return types, stypes, scales
30118
def parse(stream):
        
        definition = InputDefinition()

        # parse XML from the stream, then get the root node
        root = ET.parse(stream).getroot()

        for node in root:
            if node.tag == "configuration":
                # get config for each stanza
                definition.inputs = parse_xml_data(node, "stanza")
            else:
                definition.metadata[node.tag] = node.text

        return definition
185326
@Override
    protected void parse() {
        maximumInstances = getInt(PARAM_MAXIMUM_INSTANCES, DEFAULT_MAXIMUM_INSTANCES);
        mergeRelatedIssues = getBoolean(PARAM_MERGE_RELATED_ISSUES, true);
        overridesFilename = getString(PARAM_OVERRIDES_FILENAME, "");
    }
426358
def parse(self, parser, xml):
        """"""
        #We can only process references if the XML tag has inner-XML
        if xml.text is not None:
            matches = parser.RE_REFS.finditer(xml.text)
            if matches:
                for match in matches:
                    #Handle "special" references to this.name and param.name here.
                    self.references.append(match.group("reference"))

        #We also need to get all the XML attributes into the element
        for key in list(xml.keys()):
            self.attributes[key] = xml.get(key)
1062037
private List<?> loadDataFromXmlFile() {
        logger.entering();
        Preconditions.checkArgument(resource.getCls() != null, "Please provide a valid type.");
        List<?> returned;

        try {
            JAXBContext context = JAXBContext.newInstance(Wrapper.class, resource.getCls());
            Unmarshaller unmarshaller = context.createUnmarshaller();
            StreamSource xmlStreamSource = new StreamSource(resource.getInputStream());
            Wrapper<?> wrapper = unmarshaller.unmarshal(xmlStreamSource, Wrapper.class).getValue();
            returned = wrapper.getList();
        } catch (JAXBException excp) {
            logger.exiting(excp.getMessage());
            throw new DataProviderException("Error unmarshalling XML file.", excp);
        }

        logger.exiting(returned);
        return returned;
    }
56354
def parse_data(data, type, **kwargs):
    
    suffixes = {
        'xml': '.osm',
        'pbf': '.pbf',
    }
    try:
        suffix = suffixes[type]
    except KeyError:
        raise ValueError('Unknown data type "%s"' % type)

    fd, filename = tempfile.mkstemp(suffix=suffix)
    try:
        os.write(fd, data)
        os.close(fd)
        return parse_file(filename, **kwargs)
    finally:
        os.remove(filename)
605268
def load_xml(self, filepath):
        
        # Parse the XML file
        vot = vo.parse_single_table(filepath)
        self.raw = np.array([list(i) for i in vot.array]).T

        # Parse the filter metadata
        for p in [str(p).split() for p in vot.params]:

            # Extract the key/value pairs
            key = p[1].split('"')[1]
            val = p[-1].split('"')[1]

            # Do some formatting
            flt1 = p[2].split('"')[1] == 'float'
            flt2 = p[3].split('"')[1] == 'float'
            if flt1 or flt2:
                val = float(val)

            else:
                val = val.replace('b&apos;', '')\
                         .replace('&apos', '')\
                         .replace('&amp;', '&')\
                         .strip(';')

            # Set the attribute
            if key != 'Description':
                setattr(self, key, val)

        # Create some attributes
        self.path = filepath
        self.pixels_per_bin = self.raw.shape[-1]
        self.n_bins = 1
944623
def main_from_xml(file)
      xml_data = File.read(file)
      xml_data.force_encoding('utf-8')

      doc = Nokogiri::XML(xml_data)
      doc.elements.first.elements.first
    end
64896
public void parseFile(File file) throws ParserException, IOException {

        Reader reader = null;

        try {
            reader = new FileReader(file);
            nanoElement.parseFromReader(reader);
        } catch (XMLParseException e) {
            throw new ParserException(e.getMessage());
        } finally {
            if (reader != null) reader.close();
        }
    }
284271
def load_graph_xml(xml, filename, load_all=False):
    ''''''
    ret = []
    try:
        root = objectify.fromstring(xml)
    except Exception:
        return []
    if root.tag != 'graphs':
        return []
    if not hasattr(root, 'graph'):
        return []
    for g in root.graph:
        name = g.attrib['name']
        expressions = [e.text for e in g.expression]
        if load_all:
            ret.append(GraphDefinition(name, e, g.description.text, expressions, filename))
            continue
        if have_graph(name):
            continue
        for e in expressions:
            if expression_ok(e):
                ret.append(GraphDefinition(name, e, g.description.text, expressions, filename))
                break
    return ret
306231
def _ParsePropertiesXMLFile(self, xml_data):
    
    xml_root = ElementTree.fromstring(xml_data)

    properties = {}
    for xml_element in xml_root.iter():
      if not xml_element.text:
        continue

      # The property name is formatted as: {URL}name
      # For example: {http://purl.org/dc/terms/}modified
      _, _, name = xml_element.tag.partition('}')

      # Do not including the 'lpstr' attribute because it is very verbose.
      if name == 'lpstr':
        continue

      property_name = self._PROPERTY_NAMES.get(name, None)
      if not property_name:
        property_name = self._FormatPropertyName(name)

      properties[property_name] = xml_element.text

    return properties
1248491
def parse_xml_dataset(elem, handle_units):
    """"""
    points, units = zip(*[parse_xml_point(p) for p in elem.findall('point')])
    # Group points by the contents of each point
    datasets = {}
    for p in points:
        datasets.setdefault(tuple(p), []).append(p)

    all_units = combine_dicts(units)
    return [combine_xml_points(d, all_units, handle_units) for d in datasets.values()]
1313069
def _parse_tree(self, node):
        
        if 'filename' in node.attrib:
            self.filename = node.attrib['filename']
        if 'type' in node.attrib:
            self.kind = node.attrib['type']
        if 'target' in node.attrib:
            self.target = node.attrib['target']
        self.value = node.text
355765
def _parse_xml(self, xml):
        
        vms("Parsing <static> XML child tag.", 2)
        for child in xml:
            if "path" in child.attrib and "target" in child.attrib:
                if child.tag == "file":
                    self.files.append({"source": child.attrib["path"],
                                       "target": child.attrib["target"]})
                elif child.tag == "folder":
                    self.folders.append({"source": child.attrib["path"],
                                         "target": child.attrib["target"]})
15132
private Document parse(File file) {
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            builder.setEntityResolver(new EntityResolver() {
                @Override
                public InputSource resolveEntity(String publicId, String systemId)
                        throws SAXException, IOException {
                    return new InputSource(new StringReader(""));
                }
            });

            return builder.parse(file);
        } catch (Exception e) {
            throw new TestException(e);
        }
    }
610185
def import_from_xml(self, xml):
        '''
        
        '''
        self._import_orgid(xml)
        self._import_parents_from_xml(xml)
        self._import_instances_from_xml(xml)
        self._import_common_name(xml)
        self._import_synonyms(xml)
        self._import_dblinks(xml)
1075012
def parse(self, stream, media_type=None, parser_context=None):
        
        assert etree, 'XMLParser requires defusedxml to be installed'

        parser_context = parser_context or {}
        encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)
        parser = etree.DefusedXMLParser(encoding=encoding)
        try:
            tree = etree.parse(stream, parser=parser, forbid_dtd=True)
        except (etree.ParseError, ValueError) as exc:
            raise ParseError('XML parse error - %s' % six.text_type(exc))
        data = self._xml_convert(tree.getroot())

        return data