How do I parse a Xml String with jOOx? The parse method accepts String uri, but not Xml String.
Parse Xml String with Joox
2.3k Views Asked by quarks At
2
There are 2 best solutions below
0
On
In the simplest form it looks like this
// Parse the document from string
Document document = $(new StringReader("<?xml version='1.0'?><root><child attr='attr' /></root>")).document();
And then do your matching with
// Wrap the document with the jOOX API and find root element
Match m = $(document).find("root");
Looks like you can do it using the
JOOXclass and a StringReader. For example:See the DocumentBuilder API, which JOOX uses.
You might have to convert the
StringReaderto anInputSourceor equivalent, but that's a relatively trivial conversion. From the test case:In this case, you could write:
That should get you started. Note that there are probably simpler ways to convert a String to an input stream.