Your skill will accomplish
what the force of many cannot
XML::Simple problem, or How to convert HTML to Perl and then back again.by Wonko the sane (Deacon)
|on Jul 11, 2003 at 18:05 UTC||Need Help??|
Wonko the sane has asked for the
wisdom of the Perl Monks concerning the following question:
What I am trying to do is take a string of valid HTML, convert it into a Perl Data structure so I can easily modify the individual parts, then output the modified structure back as HTML again.
At first I though that this would be fairly easy using XML::Simple, I seem to be running into a problem when converting back to HTML though. Seems that some tags are improperly being interpreted as tag attributes, rather than the nested tags that they started out as.
I have read through the XML::Simple Documentation but have not been able to gleam a way of getting what I want out of it.
I may be going about this the wrong way entirely. Maybe this cannot effectively be done? I would be very interested in any suggestions on how I might go about doing this. I am not set on using XML::Simple, it just seemed the closest fit to the solution I could find.
Here is a code snippet that I have been working with, that almost gives me what I want.
As you can see, it seems to misinterpret the 'head' and 'tr' tags as attributes to the enclosing tags. it also does not seem to properly nest everything correctly.Any suggestions or ideas on how I can correct this, or do it another way would be much appreciated.