SimpleXML adding html into Hash tree

Posted by Miriam Raphael Roberts on Stack Overflow See other posts from Stack Overflow or by Miriam Raphael Roberts
Published on 2010-04-14T20:05:44Z Indexed on 2010/04/14 20:43 UTC
Read the original article Hit count: 299

Filed under:
|
|

Question: I have an xml file that I am pulling from the web and parsing. One of the items in the xml is a 'content' value that has HTML. I am using SimpleXML/XMLin to parse the file like so:

$xml= eval { $data->XMLin($xmldata, forcearray => 1, suppressempty=> +'') };

When I use Dumper to dump the hash, I dsicovered that SimpleXML is parsing the HTML into the hash tree.

'content' => {
      'div' => [
                 {
                   'xmlns' => 'http://www.w3.org/1999/xhtml',
                   'p' => [
                       {
                         'a' => [
                             {
                                'href' => 'http://miamiherald.typepad.com/.a/6a00d83451b26169e20133ec6f4491970b-pi',
                               'style' => 'FLOAT: left',
                               'img' => [
                                   etc.....

This is not what I want. I want to just grab content inside of this entry. How do I do this?

© Stack Overflow or respective owner

Related posts about perl

Related posts about Xml