more useful options | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
If you are trying "to find if there are any mismatched tags", that sounds like you are looking for errors that would cause an XML parser to fail (and it appears that the sample xml data you posted has this kind of problem, so I understand your goal now).
But what that really means is that you can't really use an XML parser at all to solve this problem. As pointed out above, it's easy enough to check for xml errors using xmllint, although the error reports you get can sometimes be difficult to interpret, and the actual problem can still be hard to spot. I would be inclined to use a regex-based diagnosis - something like this: That will at least give you a clear tally of imbalances (if any) in the open/close tag inventory for a given xml file. You should be able to use this information, together with the line numbers from the xmllint reports, to locate the problems. So, when you find these mismatched tags, isn't the next step to look at the process that is creating the xml files, and fix that? (These xml files aren't being created by manual editing, are they??) (Update: BTW, I forgot to mention... this new information in your reply makes your OP even more egregiously obtuse. If you had said at the beginning, "I have this xml file that has an error in the tags, and I need to figure out how to find the problem," then the discussion would have been more effective. I know, you already feel bad about the OP, and I shouldn't pile it on, but it needs to be said.) In reply to Re^3: Bug in XML::Parser
by graff
|
|