parsing html from divs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ian
    Member
    • Mar 2004
    • 64

    #1

    parsing html from divs

    Hi everyone, this is driving me nuts. There is so little info avalible on PHP5 xml features.

    Anyway, here is my code and it works with the exception that the divs it grabs only return the content in them. I want the html tags within the div also. Any ideas?

    Code:
    $dom = DomDocument::loadHTMLFile($path); // Path to html file
    $div = $dom->getElementsByTagName('div');
    foreach($div as $node) {
    	$divId = $node->getAttribute('id');
    	$divContent = $node->nodeValue;
    	$dataArray[$divId] = $divContent;
    
    }
    Now I would access the div content like this.

    Code:
    echo $dataArray['date'];
    Gives me the div with id date, but not any html within that div.

    Thanks
    www.ianhoar.com - A place to geek out
  • sdjl
    Senior Member
    • Mar 2004
    • 502

    #2
    It could be that it's stripping out the HTML through an inbuilt function.
    I've no idea where though as i've not used the DOM XML functions.

    It may be worth asking on a specialised forum like devshed or sitepoint.

    David
    -----
    Do you fear the obsolescence of the metanarrative apparatus of legitimation?

    Comment

    • Ian
      Member
      • Mar 2004
      • 64

      #3
      I think it is, I've tried htmlforums php forum. Its such a simple chunk of code, would be so nice if you could just dump the markup with it. Would make my day a lot easier too.
      www.ianhoar.com - A place to geek out

      Comment

      Working...