1

I'm uploading and xml file using a php class I wrote. What I need is I need to check if ReadingDate exists in the xml or not.

<ProductCollect ReadingDate="2013-09-12T11:39:57.763">

I can get ProductCollect but how to access ReadingDate?

1 Answer 1

1

To get an attribute with XPath

/ProductCollect/@ReadingDate
Sign up to request clarification or add additional context in comments.

3 Comments

But what if it was like <ProductCollect ReadingDate="2013-09-12T11:39:57.763" Test="asd"> And I wanted to access Test . /ProductCollect/@Test or /ProductCollect/@ReadingDate/@Test ???
/ProductCollect/@Test
To explain why /ProductCollect/@ReadingDate/@Test wouldn't make sense: XPath is looking at the hierarchy, not the sequence. Test and ReadingDate are both at the same level of the hierarchy, one is not a child of the other; which order they appear in is irrelevant.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.