Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: XML::Parser XML validation

by choroba (Chancellor)
on Jan 05, 2013 at 11:32 UTC ( #1011782=note: print w/replies, xml ) Need Help??


in reply to XML::Parser XML validation

The parser cannot know how to fix the first error it finds. The other errors, therefore, might lack information value. Consider the following document:
<r> <a> <b> <c> </b> </a> </r>
The problem is the missing </c>. But the parser might tell you:
Start and end tag mismatch: c and b, line 5. Start and end tag mismatch: b and a, line 6. Start and end tag mismatch: a and r, line 7. Unexpected end of the document, line 7.
BTW, that's roughly what xmllint would tell you.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: XML::Parser XML validation
by Anonymous Monk on Jan 05, 2013 at 11:35 UTC
    Thanks for your quick answer. So basically, I will have to fix any error found by the script and then re-run, fix any new error and repeat the procedure until there are no more errors?
      Yes. All bets are off for an XML document with errors. The first error found may actually not be the first error in the document: it is just the place where the parser got stuck.

      Consider the following:

      <a> <d> <e> </e> </b> </a>
      Where is the error? Should <d> be <b> or should </b> be </d>? Or perhaps they should both be <f> ... </f> tags? How is the parser to know? To be sure the XML is not only well formed but also correct, you will have to validate the XML according to a DTD or Schema definition.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      My blog: Imperial Deltronics

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1011782]
help
Chatterbox?
[perldigious]: If I was given the option to remove either mosquitos or ticks from the world... I think I'd pick ticks, even though I'd guess most would go the other way.
[Lotus1]: when they grooms themselves they eat any ticks they find. and apparently lots of ticks latch onto opossums.
[Your Mother]: There is a nice looking—don’t know first hand—new tool being market for removing ticks.
[Your Mother]: (marketed)
[Lotus1]: at least ticks don't fly
[1nickt]: We have a new tick in cenral New Jersey this year. The Lone Star tick -- no Lyme, but will give you an allergy to red meat!
[Your Mother]: "Tick Twister."
[1nickt]: My sister lives in the Sydney suburbs (carved out of the bush) and they have the Paralysis tick -- leavs you quadriplegic!
[perldigious]: Hmm, thanks Lotus1... perldigious scribbles note to buy lots of opossums as "pets" in the future to hang around outside his property. :-P
[1nickt]: You must twist and pull! If you burn, use tea tree oil etc, the tick barfs (inside your blood vessel) and you get all the loevely bacteria in his gut transferred to yours.

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (14)
As of 2017-05-24 13:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?