Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing XML Data - Error

Status
Not open for further replies.

Utnapishtim

IS-IT--Management
Joined
Jan 29, 2004
Messages
6
Location
US
I am trying to parse an XML file using VB.Net using the XMLValidatingReader method. The XML file contains a soap header, followed by several document iterations. The structure follows:

<?xml version="1.0" encoding="UTF-8" ?>
<SOAP:Envelope xmlns="http:...">
<Soap:Header>
</SOAP:Header>
<Soap:Body>
</Soap:Body>
</SOAP:Envelope>
<?xml version="1.0" encoding="UTF-8" ?>
<RecordData documentcount="2" xlmns="...">
.
.
.
</RecordData>
<?xml version="1.0" encoding="UTF-8" ?>
<RecordData documentcount="2" xlmns="...">>
.
.
.
</RecordData>

The significant error indicates that there is an unexpected XML declaration. I am assuming that the problem lies in the fact that multiple iterations of the <?xml declaration exist. How can I treat each of the documents within the xml declaration as separate entities to be parsed?
 
Right now, with those extra <?xml> tags in there, it's not a valid XML document. You should attempt to get the sender to not do that.

Otherwise, you'll need to use a TextReader, and read up until you have a complete record, and then process it. Your validation will then occur on a per-record level, not at the document level.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Chip,
Thanks for the hint. What I just realized is that the sender is providing me with information embedded in something called mime multi-part. Those invalid ?xml tags mean something in the mime world. Now it's left to me to find another reader that will bracket whatever data lies within the mime envelope, and send the appropriate data to another file, where parsing can begin in earnest.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top