in reply to Valid XML and XML::Simple

Where does w3c say that that is not valid XML? The XML spec in part says:

[4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
[5] Name ::= (Letter | '_' | ':') (NameChar)*

and:

The Namespaces in XML Recommendation XML Names assigns a meaning to names containing colon characters. Therefore, authors should not use the colon in XML names except for namespace purposes, but XML processors must accept the colon as a name character.

which makes it pretty clear that colons not only are allowed, but must be accepted by XML processors.


Perl is environmentally friendly - it saves trees

Replies are listed 'Best First'.
Re^2: Valid XML and XML::Simple
by mrguy123 (Hermit) on Oct 28, 2007 at 09:54 UTC
    Hi,
    I'm assuming this is not black and white, but the fact is that if you save my example as an XML file, and try to open it, you get an error. It also fails when I try to parse it in "C".
      The foo:thing syntax relates to namespaces. An XML parser must accept such syntax (here the node is a 'thing' in the 'foo' namespace).

      The document should be considered invalid because the 'person' namespace has not been declared at the top of the XML document.

      However, XML::Simple is (as it's name implies) a simplistic approach to parsing XML... it's not exactly a strict parser. It may or may not give you a warning about a missing 'prefix'.

      Use a more compliant parser such as XML::Parser (directly), XML::Twig or XML::LibXML.

      -David

Re^2: Valid XML and XML::Simple
by mrguy123 (Hermit) on Oct 28, 2007 at 10:10 UTC
    Hi again
    I added this in the decription: if you try to validate this XML in the w3schools page (http://www.w3schools.com/dom/dom_validate.asp) you get an error