Skip to main content
1-Visitor
February 15, 2013
Question

Parsing XML in Java

  • February 15, 2013
  • 2 replies
  • 1044 views

Hello! I have to use obsolete Arbortext Editor 5.2. I need to collect text from XML in a certain way (I need to put '\n' for some text nodes in result string). I've already made a function in Java 5 which executes this using activeDocument. But I have problems using internal Java shipped with Arbortext Editor when I deal with unopenedXML files.


I want to get org.w3c.dom.Document object and then pass it to my function.I used default code with DocumentBuilder factory, it led to


org.apache.xerces.dom.DeferredDocumentImpl exception.

I try to use DOMParser which implementation is here:xercesImpl.jar


I need to ignore "DTDs not found"/namspace errors.

    2 replies

    1-Visitor
    February 15, 2013
    Ilya,

    Look at com.arbortext.epic.Application.openDocument(). There are flags you can pass to that method to control things like whether error messages are displayed. I believe in 5.2 the javadoc was under the 'doc' directory in the install tree.

    Chris

    1-Visitor
    February 15, 2013
    Another option, and this is something we also used in 5.x, is to use the
    org.apache.xerces.parsers.DOMParser.

    eg:
    DOMParser parser = new DOMParser();
    parser.parse(filePath);
    Document doc = parser.getDocument();

    - keith


    On Fri, Feb 15, 2013 at 7:54 AM, Chris Nitchie <chris.nitchie@oberontech.com<br/>> wrote:

    > Ilya,
    >
    > Look at com.arbortext.epic.Application.openDocument(). There are flags you
    > can pass to that method to control things like whether error messages are
    > displayed. I believe in 5.2 the javadoc was under the 'doc' directory in
    > the install tree.
    >
    > Chris
    >
    >