I'm following this turorial on parsing XML with XPath, and it gives the following example to open a document:
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
domFactory.setNamespaceAware(true); // never forget this!
DocumentBuilder builder = domFactory.newDocumentBuilder();
Document doc = builder.parse("books.xml");
What I would like to do, is change that so that the Document is reading a String variable that I already have made, instead of reading from a file. How can I do that?
builder.parse(new InputSource(new StringReader("<some><xml></xml></some>")));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With