Sunday, March 31, 2019

XML Parsing Using Java org.w3c.dom

You might often have challenging XML data to be parsed. This is an example showing you how to parse XML data efficiently using Java org.w3c.domImage title

XML Data to Be Parsed:

<?xml version="1.0"?>
<COMMAND>
    <DATA>
        <TXNID>1234567891</TXNID>
        <TXNAMT>15.00</TXNAMT>
        <TXNID>1234567892</TXNID>
        <TXNAMT>15.00</TXNAMT>
        <TXNID>1234567893</TXNID>
        <TXNAMT>15.00</TXNAMT>
        <TXNID>1234567894</TXNID>
        <TXNAMT>15.00</TXNAMT>
    </DATA>
</COMMAND>

Most XML data can easily be parsed through JAXB, but there are situations like the above where we need to do manual parsing. If we give the above XML data to JAXB, it's quite obvious that JAXB can not churn it around and give you a clean object mapping. This is where XML parsers like org.w3c.dom and others come into play.



from DZone.com Feed https://ift.tt/2CMqKhI

No comments:

Post a Comment