Manikandarajan
Manikandarajan

Reputation: 21

JDOM HTML to XML Conversion - parent node selfend tag generating eventhough it having a child node

JDOM parser used for parsing and conversion of html file to XML file. After parsing the html file self end tag generating even though it has a child node. Input Html

<li id="fieldId1" fieldtype="dropdownFromList">
    <span>
    <sflabel path="polProdCode">
    <fmtmessage key="mpolicy.policy.polProdCode.lable" />
    </sflabel>
    </span>
</li>

OutputXML

         <span>
         <sflabel path="polProdCode" />  ---sflabel tag selfclosing after the conversion
         <fmtmessage key="mpolicy.policy.polProdCode.lable" />
         </span>

Expected XML

          <span>
          <sflabel path="polProdCode" >
          <fmtmessage key="mpolicy.policy.polProdCode.lable" />
          </sflabel>      ----need endtag
          </span>

Java Code

    SAXBuilder saxBuilder = new SAXBuilder("org.ccil.cowan.tagsoup.Parser", false);
File log = new File("log.html");
        org.jdom.Document jdomDocument = saxBuilder.build(log);
        XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());

            fwOutXml = new FileWriter("output.xml");
            bwOutXml = new BufferedWriter(fwOutXml);
            outputter.output(jdomDocument, bwOutXml);

Upvotes: 0

Views: 301

Answers (1)

Manikandarajan
Manikandarajan

Reputation: 21

I've fixed the conversion by removing the saxdriverclass and left empty

     SAXBuilder saxBuilder = new SAXBuilder();

Upvotes: 0

Related Questions