Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: XML cleanup - regex or ?

by ikegami (Patriarch)
on Sep 21, 2010 at 16:27 UTC ( [id://861107]=note: print w/replies, xml ) Need Help??


in reply to Re^2: XML cleanup - regex or ?
in thread XML cleanup - regex or ?

It's not an XML error to be missing a meow attribute on a cat element. Did you misrepresent the problem, or are you actually getting the error when you validate the XML against a schema? There's no reason you can't do that after removing the offending elements.

Replies are listed 'Best First'.
Re^4: XML cleanup - regex or ?
by dHarry (Abbot) on Sep 22, 2010 at 07:21 UTC

    It's not an XML error to be missing a meow attribute on a cat element.

    That depends, if the attribute is mandatory it would be an error. Or do you mean something else by XML error? I'm thinking XSD here but I recall that with DTD's you can also specify attributes and make them "required".

    Cheers

    Harry

      XML doesn't have any mandatory attributes on any elements. It doesn't even define any elements. As I suggested, you are talking of validation errors and not parsing errors. Those are two unrelated concepts. You need not validate the XML the parse it and manipulate it.

        I don't disagree with you, I didn't get what you mean by "XML error" and I'm afraid I still don't get it. If you mean that with "missing attributes" you can still parse the file because it remains "well formed" I agree. A XML parser can parse any wellformed XML document, otherwise it would not be compliant. Missing attributes won't make a difference. In order for a XML document to be wellformed you need at least a root element though. What got me on the wrong foot is that the OP mentions he knows what attributes to expect, I sort of assumed he has schema(s) and/or DTD(s) and therefore a validating parser. Validation is optional of course.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://861107]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-16 16:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found