0

How would you access the value of 'seconds' within this XML code using PHP?

<entry><yt:duration seconds='339'/></entry> 

So far I have:

$xml -> entry -> ?!?

For Serty:

<?xml version='1.0' encoding='UTF-8'?> 
4
  • 1
    What XML library to you use to get $xml variable ? Commented Mar 29, 2011 at 21:39
  • Is this the line you are looking for? Commented Mar 29, 2011 at 21:43
  • 1
    You don't edit your post as answered, you mark the correct answer below with the tick mark next to it Commented Mar 29, 2011 at 21:56
  • 1
    Also increase the point counter if you are very happy with the quality of the answer.. Commented Mar 29, 2011 at 21:57

1 Answer 1

2

Well, what you are looking for is called an attribute. If you are using php to parse your xml, then I would look at http://php.net/manual/en/domelement.getattribute.php, and find a comment that helps you.

Without knowing how you are parsing it though, I can't help much more

Sign up to request clarification or add additional context in comments.

4 Comments

How do you get around the yt namespace though? (i think that's the first part of the question
What do you mean by the yt namespace?
well the duration tag is namespaced yt. In simplexml (which is what I assume Will is using), is it as simple as ignoring the name space, or is there a particular way to reference the tag as $xml->entry->duration ?
Interesting, I'm also curious if there is a way to check the namespace

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.