By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,813 Members | 2,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,813 IT Pros & Developers. It's quick & easy.

Question about php domelement objects

P: n/a

Hello all. When I do a print_r of a domelement object I get something like this:

domelement Object
(
[type] => 1
[tagname] => category
[0] => 6
[1] => 1007543104
)

What are those "0" and "1" internal variables? I can not seem to find any description
of them anywhere. What do they represent? The "0" one seems to stay constant with a
constant xml source. But the "1" one is always different though still unique. Are
these variables a php thing only? Or part of the dom specification that I missed?

Also how do I access them? I can do a "$node->tagname" or "$node->type" just fine to
get access to those internal object variables. But php does not like "$node->0" at all.
What's the problem? Some kinda of variable scoping or something?

Lastly, I don't suppose there is any way to search by these "0" variables with an
xpath_eval statement?

The problem is this: I will be receiving an xml file with all these nested "category"
elements. They only have "name" attributes, which unfortunately, I can not be guaranteed
will be unique. But I still need some unique way to identify them. Short of adding
attributes to each "category" element, I was hoping to use this "0" internal object
variable, or perhaps, the position() function from xpath. But I have no idea how to
determine an elements position when all I have is the domelement object.

Thanks for any help!

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
George Thorogood wrote:
Hello all. When I do a print_r of a domelement object I get
something like this:

domelement Object
(
[type] => 1
[tagname] => category
[0] => 6
[1] => 1007543104
)

What are those "0" and "1" internal variables? I
I was unable to reproduce this output, can you post a snippet which results
in this?
But I have
no idea how to determine an elements position when all I have is the
domelement object.


With an XPath expression, you can group category elements with equal values
for the name attributes:

//category[@name='value']

If you want the first matching node, just do:

//category[@name='value'][1]
JW

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.