Login   Register  
PHP Classes
elePHPant
Icontem

Accesing nodes like ns:stuff

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      SimpleXML for PHP4  >  All threads  >  Accesing nodes like ns:stuff  >  (Un) Subscribe thread alerts  
Subject:Accesing nodes like ns:stuff
Summary:Is there any way to access nodes like ns:stuff
Messages:5
Author:DarkStar77
Date:2008-06-20 04:45:55
Update:2011-11-30 15:59:12
 

  1. Accesing nodes like ns:stuff   Reply  
Picture of DarkStar77
DarkStar77
2008-06-20 04:45:55
I see in your docs that you said you will add a way to access nodes by converting ns:stuff to ns_stuff. Has this been done yet? If not is there any way to access this using your current code base? Thanks for all our hard work, it is greatly appreciated.

  2. Re: Accesing nodes like ns:stuff   Reply  
Picture of DarkStar77
DarkStar77
2008-06-21 05:12:09 - In reply to message 1 from DarkStar77
FYI: found a work around by type casting the SimpleXMLObject to an array, this allowed me to access these nodes. (ex: $array = (array)$object; )

  3. Re: Accesing nodes like ns:stuff   Reply  
Picture of Taha Paksu
Taha Paksu
2008-07-16 15:10:52 - In reply to message 2 from DarkStar77
thats interesting :) I didn't thought like that before.. btw i did what you said in your first message but i think i forgot to post it here :) thats not so hard all you need is to edit array_insert function and add a replace function before building the code to be eval'd.

  4. Re: Accesing nodes like ns:stuff   Reply  
Picture of Antonius Aji
Antonius Aji
2008-10-04 05:03:25 - In reply to message 1 from DarkStar77
this what I do:

$data = $sxml -> xml_load_file ($file);
echo "ns:stuff".$data->{'ns:stuff'}

in essence make an array with the content of 'ns:stuff' string.


It is excellent class as alternative for simplexml in PHP4, I wish there is a simple documentation with many example just like the way people explain in php.org

I have to do some experimentation to understand how to retrieve data.


rgds,
antonius aji

  5. Namespaces Work - $item->{"name:space"};   Reply  
Picture of Joshua Jackson
Joshua Jackson
2011-11-30 15:59:13 - In reply to message 4 from Antonius Aji
Well...
While I was typing this post to get some help, I figured out how to get namespaces working.
echo $item->{"name:space"};
I spent about an hour trying to figure out why the previous example of $data->{'ns:stuff'} wasn't working.
Hehehe...
JJ

Example xml...
<rss>
<channel>
<item>
<title>Title</title>
<mlm:location>Branson, MO</mlm:location>
</item>
</channel>
</rss>

Example code...
<?php echo $item->{"mlm:location"}; ?>

Example output...
Branson, MO