How to convert string to xml

I have a string that contains XML data, and I want to convert it to an XML document object. How to do it?

+3
source share
3 answers

say theString contains XML,

        DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
        Document doc = docBuilder.parse(new InputSource(new StringReader(theString)));

More here

+8
source

All you have to do is pass the string to the LoadXml method of the XmlDocument Class. Then you can use XPath to get the values ​​of the elements / attributes in the document.

0
source

.

XML, JAXB . , , JDOM SAXON.

0

Source: https://habr.com/ru/post/1773767/


All Articles