Java NonValidatingDomParser problem with blank lines in XML

D

derek b

I can parse files with no problem. The issue comes in when I am
actually going through the document to populate my objects. Any blank
lines are coming in as "#text" items. I can easily enough force the
items to "instanceof element", but I figured there has to be someway
to let java handle this.

For instance the following XML show up with 2 lines with a value of
#text.

<ShipToSection>
<ShipToName>Test user</ShipToName>
<ShipToAddress1>New Test Line 1</ShipToAddress1>


<ShipToAddress2>Address Line 2</ShipToAddress2>
<ShipToCity>Oak Park</ShipToCity>
<ShipToState>IL</ShipToState>
<ShipToPostalCode>60302</ShipToPostalCode>
<ShipToCountry>US</ShipToCountry>
<ShipToPhoneNum>555-555-5555</ShipToPhoneNum>
</ShipToSection>

In testing it, I find if I do use a DOM it controls those values,
however I am not in a position choose to create a DOM. We are
receiving this from another vender which is not providing a DOM.

As I said before I can check the values to be "instanceof element",
but I figured thats going to provide a bit of unwanted overhead for
every line. I figure the parser can do this, I just don't know how.
I basically want all opening and closing tags, and any text elements
that may fall between the open and close. I have tried playing with
the ignorablewhitespace() method...but that doesn't seem to do what I
need.

Thanks for any help you can provide
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top