http://qs321.pair.com?node_id=384584


in reply to Re^3: Generating elements with attributes and contents using XML::Smart
in thread Generating elements with attributes and contents using XML::Smart

I made these corrections to my full program and DTD and I still have a problem. If I have a 'type' element defined, then the 'type' attribute is still getting converted to a tag inside the 'phone' element.

use XML::Smart; my $xml = XML::Smart->new; $xml->{customer}{phone} = "555-1234"; $xml->{customer}{phone}{type} = "home"; $xml->apply_dtd(<<EOF); <?xml version="1.0" ?> <!DOCTYPE customer [ <!ELEMENT customer (type?,phone+)> <!ELEMENT phone (#PCDATA)> <!ATTLIST phone type CDATA #REQUIRED> <!ELEMENT type (#PCDATA)> ]> EOF print $xml->data;

This produces:

<customer> <phone> <type>home</type>555-1234</phone> </customer>
90% of every Perl application is already written.
dragonchild