|There's more than one way to do things|
XML::Twig generating invalid XHTML output??by nick (Sexton)
|on Feb 14, 2005 at 17:16 UTC||Need Help??|
nick has asked for the wisdom of the Perl Monks concerning the following question:
I've been working on an XHTML parser, and for the most part I really like XML::Twig, it's very powerfull yet still fairly easy to use. However, there is still some weirdness that I cannot figure out how to fix.
For example, if I load in a valid XHTML document, add a field to it (such as a form tag), then output the parsed data. I would expect the output would be valid XHTML as well, but it isn't. See example:
This is my valid XHTML document:
Here is my code, which will insert a form tag into the body.
This is simple code to input form tags, and it works, the form tags are inserted, however the output of XML::Twig generates invalid XHTML. See output:
Notice the closing, and then re-opening of the html tag right after the head, and before the body. When I try to parse this outputed file with XML::Twig it gets an error right at that spot. Removing the offending lines resolves the problem.
So my question is, how do I get XML::Twig to output valid XHTML after adding this form tag?
Thanks in advance for any help!