0

Possible Duplicate:
Parse XML with Namespace using SimpleXML

how do i get the attribute value of seconds from the XML code below:

<yt:duration seconds='12445'/> 

is it possible to use simplexml.

Thank you

2
  • Assuming your xml content in text.xml $file = 'test.xml'; $xmlstr = file_get_contents($file); $xml_content = new SimpleXMLElement($xmlstr); echo $xml_content->attributes()->seconds; Commented Aug 4, 2012 at 17:52
  • $string = <<<XML <yt:duration seconds='12445'/> XML; $xml = simplexml_load_string($string); foreach($xml->attributes() as $a) { echo $a; } output:- 12445 Commented Aug 4, 2012 at 18:29

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.