Parses a XML file and returns a Config object holding the information.
@param xml source of the xml data
@return
@throws IOException
@throws SAXException
189250
public static Config parse(InputSource xml) throws IOException, SAXException {
		Config rv = new Config();
		XMLReader reader = XMLReaderFactory.createXMLReader();
		ConfigHandler handler = rv.new ConfigHandler(rv);
		reader.setContentHandler(handler);
		reader.parse(xml);
		return rv;
	}
739406
public static Document toDocument(String xml) throws SAXException {
		try {
			return toDocument(new StringReader(xml));
		} catch (IOException e) {
			//reading from string
			throw new RuntimeException(e);
		}
	}
728968
public static Document stringToDocument(String xml) {
        try {
            SAXBuilder sax = new SAXBuilder();
            return sax.build(new ByteArrayInputStream(xml.getBytes("UTF-8")));
        } catch (JDOMException e) {
            throw new IllegalArgumentException("Unable to parse xml", e);
        } catch (IOException e) {
            throw new IllegalArgumentException("Unable to parse xml", e);
        }
    }
629054
private void writeXML(String xml) {
        String resourceName = System.getProperty(CONFIG_FILENAME_KEY);
        if (resourceName == null) {
            return;
        } else {
            URL rUrl = ClassLoader.getSystemResource(resourceName);
            if (rUrl != null) {
                File file = new File(rUrl.getFile());
                if (file != null && file.canWrite()) {
                    FileWriter fw = null;
                    try {
                        fw = new FileWriter(file);
                        fw.write(xml);
                        fw.close();
                    } catch (IOException ioe) {
                        //@TODO log it?
                    } finally {
                        try {
                            fw.close();
                        } catch (IOException ioee) {
                            ; //Nothing to do.
                        }
                        fw = null;
                        file = null;
                    }
                }
            }
        }
    }
940704
public static Api fromXML(final String xml) throws Exception {
  	Api result=null;
  	try {
  	  result=apifactory.fromXML(xml);
  	} catch (JAXBException je) {
  		LOGGER.log(Level.SEVERE,je.getMessage());
  		LOGGER.log(Level.INFO,xml);
  		throw je;
  	}
    return result;
  }
893035
public JSON read( String xml ) {
      JSON json = null;
      try{
         Document doc = new Builder().build( new StringReader( xml ) );
         Element root = doc.getRootElement();
         if( isNullObject( root ) ){
            return JSONNull.getInstance();
         }
         String defaultType = getType( root, JSONTypes.STRING );
         if( isArray( root, true ) ){
            json = processArrayElement( root, defaultType );
            if( forceTopLevelObject ){
               String key = removeNamespacePrefix( root.getQualifiedName() );
               json = new JSONObject().element( key, json );
            }
         }else{
            json = processObjectElement( root, defaultType );
            if( forceTopLevelObject ){
               String key = removeNamespacePrefix( root.getQualifiedName() );
               json = new JSONObject().element( key, json );
            }
         }
      }catch( JSONException jsone ){
         throw jsone;
      }catch( Exception e ){
         throw new JSONException( e );
      }
      return json;
   }
1068757
public static Config parse(InputStream in) throws XmlPullParserException, IOException {
        try {
            XmlPullParser parser = Xml.newPullParser();
            parser.setInput(in, null);
            parser.nextTag();
            return readFamilies(parser);
        } finally {
            in.close();
        }
    }
344718
public void parse(File f, DefaultHandler dh) throws SAXException, IOException
    {
        XMLReader reader = getXMLReader();
        InputSource source = new InputSource(new FileInputStream(f));
        reader.setContentHandler(dh);
        reader.parse(source);
    }
580551
function parse(xml) {
    var parser = domParserArg ? new dom.DOMParser(domParserArg) : new dom.DOMParser();
    var doc;
    try {
        doc = parser.parseFromString(xml, 'application/xml');
    } catch (e) {
        throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml: ' + e.message);
    }
    if (!doc.documentElement) {
        throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml');
    }
    var parserError = doc.getElementsByTagName('parsererror')[0];
    if (parserError) {
        throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml: ' + parserError.textContent);
    }
    return doc;
}
419444
public void readConfig(Reader reader) throws IOException {
		try {
			XMLStreamReader xr = XMLInputFactory.newInstance().createXMLStreamReader(reader);
			try {
				while (!xr.isStartElement()) {
					xr.next();
				}
				processStartElement(xr, "simon-configuration");
				while (true) {
					if (isStartTag(xr, "callback")) {
						manager.callback().addCallback(processCallback(xr));
					} else if (isStartTag(xr, "filter-callback")) {
						manager.callback().addCallback(processFilterCallback(xr));
					} else if (isStartTag(xr, "simon")) {
						processSimon(xr);
					} else {
						break;
					}
				}
				assertEndTag(xr, "simon-configuration");
			} finally {
				xr.close();
			}
		} catch (XMLStreamException e) {
			manager.callback().onManagerWarning(null, e);
		} catch (SimonException e) {
			manager.callback().onManagerWarning(e.getMessage(), e);
		}
	}
293654
public static Report loadReport(String xml) throws LoadReportException {
		try {
			String convertedXml = ConverterChain.applyFromXml(xml);
			XStream xstream = XStreamFactory.createXStream();
			return (Report) xstream.fromXML(convertedXml);
		} catch (ConverterException ex) {
			LOG.error(ex.getMessage(), ex);
			throw new LoadReportException(ex.getMessage(), ex);
		}
	}
1169546
def parse_xml_node(self, node):
        '''

        '''
        self.id = node.getAttributeNS(RTS_NS, 'id')
        self._config_data = []
        for d in node.getElementsByTagNameNS(RTS_NS, 'ConfigurationData'):
            self._config_data.append(ConfigurationData().parse_xml_node(d))
        return self
301984
public static Document toDocument(File file) throws SAXException, IOException {
		InputStream in = new BufferedInputStream(new FileInputStream(file));
		try {
			return XmlUtils.toDocument(in);
		} finally {
			in.close();
		}
	}
190848
public static XElement parseXML(XMLStreamReader in) throws XMLStreamException {
        XElement root = parseXMLFragment(in);
        in.close();
        return root;
    }
1358745
@SuppressWarnings("unchecked")
	public static <T> T readObjectFromXml(InputSource source) throws IOException {
		Object result = null;
		XMLDecoder xmldec = null;
		try {
			xmldec = new XMLDecoder(source);
			result = xmldec.readObject();
		} finally {
			IoUtil.close(xmldec);
		}
		return (T) result;
	}
1061724
@SuppressWarnings("unchecked")
    public Map<String, Object> parse(String xml) {
        try {
            Document document = parseText(xml);
            Element root = document.getRootElement();
            if (root.elements().size() == 0) {
                Map<String, Object> map = new HashMap<>();
                map.put(root.getName(), root.getText());
                return map;
            } else {
                return (HashMap<String, Object>) parse(root);
            }
        } catch (Exception e) {
            log.error("xml格式不正确", e);
            return null;
        }
    }
441727
private void parse(String fileName, @WillClose InputStream stream) throws IOException, SAXException {
        try {
            SAXBugCollectionHandler handler = new SAXBugCollectionHandler(this, new File(fileName));
            XMLReader xr = XMLReaderFactory.createXMLReader();
            xr.setContentHandler(handler);
            xr.setErrorHandler(handler);
            Reader reader = Util.getReader(stream);
            xr.parse(new InputSource(reader));
        } finally {
            Util.closeSilently(stream);
        }
    }