in reply to Parse with XML::Simple: how to keep some tags "unparsed"?

This is not valid XML. You have a tag, "<content>" that contains both a value "This is", and a child tag "<div class="red">some HTML text</div>". Pick one, or hide the <> characters with &lt;&gt;, or do the right thing and use CDATA.

Update: I stand corrected. I just checked the XML spec (http://www.w3.org/TR/2004/REC-xml-20040204) and gellyfish and ktingle are correct. Sorry.

Replies are listed 'Best First'.
Re^2: Parse with XML::Simple: how to keep some tags "unparsed"?
by gellyfish (Monsignor) on Jul 01, 2004 at 13:40 UTC

    It actually is valid - an node is allowed to have mixed content. This snippet will give rise to a schema like:

    <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="page"> <xs:complexType> <xs:sequence> <xs:element name="content"> <xs:complexType mixed="true"> <xs:sequence> <xs:element name="div"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute use="required" type="xs:string" na +me="class" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute use="required" type="xs:unsignedByte" name="id" /> </xs:complexType> </xs:element> </xs:schema>

    However this is certainly not what was intended - if the contents of <content /> are to be taken literally it should be a CDATA section.

    /J\

Re^2: Parse with XML::Simple: how to keep some tags "unparsed"?
by ktingle (Sexton) on Jul 01, 2004 at 14:23 UTC
    An element can have a value and a child element, check the XML spec. Its awkward, but valid XML.