SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Belgium
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy finding nodes with simplexml and xpath

    Hi all,
    I have the following piece of xml:
    HTML Code:
    <?xml version="1.0" encoding="UTF-8"?> <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <sitemap>
      <loc>http://f1technical8/sitemap.f1devblog.xml.gz</loc>
      <lastmod>2007-04-01T11:51:45+02:00</lastmod></sitemap>
    </sitemapindex>
    And would like to get all the sitemap nodes, so I do:
    PHP Code:
    $sxml simplexml_load_string($xml);
    var_dump($sxml);
    echo 
    "<br>";
    foreach(
    $sxml->sitemap as $item) {
        echo 
    $item "\n";


    Somehow the looping through these nodes doesn't work. The dum_var of my simplexml does look ok:
    Code:
    object(SimpleXMLElement)#10 (1) { ["sitemap"]=>  object(SimpleXMLElement)#11 (2) { ["loc"]=>  string(44) "http://f1technical8/sitemap.f1devblog.xml.gz" ["lastmod"]=>  string(25) "2007-04-01T11:51:45+02:00" } }
    Can anyone explain why this isn't working?
    It would be such a great help...

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have a look on this function SimpleXMLElement->xpath. But if you want to use domxml, please try to have a look on that. http://devzone.zend.com/node/view/id/1713
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •