Xml WellFormedness error
-
Good Morning Every one, I have an application that is going to recieve Xml file from another application via Http post. the file structure would be as follows: one rot node 100 childnodes and 4 childnodes for each among 100. i am using XmlTextReader class to parse through the Xml file. the application goes on smooth as long as the structure of Xml file is correct. if there is a welformedness error in any one of the childnodes then the reader halts at that point and throws an XML error that "The starting tag doesdont match the ending tag".Once the parser encounters this error its stops reading. I have done research and found out that XMlWellformedness eror is a fatal error and The parser is not allowed to overcome this error untill the Xmlfile structure is corrected as per the standard specifications. i wanted to know Is there any way programaticaly that i can overcome this error! right now im using XmlTextReader class for parsing and While loop to iterate through the nodes step by step sequentially. I would really appreciate if some one could guide me! Abhi Manav
-
Good Morning Every one, I have an application that is going to recieve Xml file from another application via Http post. the file structure would be as follows: one rot node 100 childnodes and 4 childnodes for each among 100. i am using XmlTextReader class to parse through the Xml file. the application goes on smooth as long as the structure of Xml file is correct. if there is a welformedness error in any one of the childnodes then the reader halts at that point and throws an XML error that "The starting tag doesdont match the ending tag".Once the parser encounters this error its stops reading. I have done research and found out that XMlWellformedness eror is a fatal error and The parser is not allowed to overcome this error untill the Xmlfile structure is corrected as per the standard specifications. i wanted to know Is there any way programaticaly that i can overcome this error! right now im using XmlTextReader class for parsing and While loop to iterate through the nodes step by step sequentially. I would really appreciate if some one could guide me! Abhi Manav
Abhi Manav wrote:
I have an application that is going to recieve Xml file from another application via Http post.
Abhi Manav wrote:
the application goes on smooth as long as the structure of Xml file is correct. if there is a welformedness error in any one of the childnodes then the reader halts at that point and throws an XML error that "The starting tag doesdont match the ending tag".
Can't you fix the other app so it produces correct XML?
[My Blog]
"Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe -
Abhi Manav wrote:
I have an application that is going to recieve Xml file from another application via Http post.
Abhi Manav wrote:
the application goes on smooth as long as the structure of Xml file is correct. if there is a welformedness error in any one of the childnodes then the reader halts at that point and throws an XML error that "The starting tag doesdont match the ending tag".
Can't you fix the other app so it produces correct XML?
[My Blog]
"Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne MetcalfeGeneration of Xml file is in Clients hands! I was just trying to figure out my application in such scenarios! Is there any way to resolve my problem?!
-
Generation of Xml file is in Clients hands! I was just trying to figure out my application in such scenarios! Is there any way to resolve my problem?!
I've never seen a parser that deals with the non-wellformed XML in a way other than throwing an exception or returning an error. The syntactic wellformedness is at the very heart of XML and if your client continues to produce XML that is not wellformed he and his partners will have many problems processing these documents. Until your client produces wellformed XML you could try to find an error-tolerant parser. If you cannot find any, you may be able to write one yourself (either generally applicable or specialized on the files you're reading). Also you may be able to write some code that deals with XML file as plain text and repairs it, so the XML parser can read it without errors.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
I've never seen a parser that deals with the non-wellformed XML in a way other than throwing an exception or returning an error. The syntactic wellformedness is at the very heart of XML and if your client continues to produce XML that is not wellformed he and his partners will have many problems processing these documents. Until your client produces wellformed XML you could try to find an error-tolerant parser. If you cannot find any, you may be able to write one yourself (either generally applicable or specialized on the files you're reading). Also you may be able to write some code that deals with XML file as plain text and repairs it, so the XML parser can read it without errors.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
Thanks a ton for the advice! i will work on the Xml repair API, hope it would be usefull in other cases too! i l get back once i comeplete the thing! Thanks!