1

I have an XmlObject I got from an Apache POI textRun. Its string representation looks like this:

<xml-fragment xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
  <a:rPr altLang="en-US" dirty="0" lang="en-US">
    <a:highlight>
      <a:srgbClr val="FFFF00"/>
    </a:highlight>
  </a:rPr>
  <a:t>Wonder</a:t>
</xml-fragment>

I'd like to extract the a:highlight field.

I can extract the value by building a Document using this code

    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document document = documentBuilder.parse(new InputSource(new StringReader(runXml.xmlText())));

and then using the Document's methods, but I want to know if there's anyway to get the field without creating the Document.

  • you can use search on stack overflow, post like this was a lot, here is one of them https://stackoverflow.com/questions/7704827/java-reading-xml-file – noname Aug 27 '19 at 22:38
  • Possible duplicate of [Java - Reading XML file](https://stackoverflow.com/questions/7704827/java-reading-xml-file) – noname Aug 27 '19 at 22:38

0 Answers0