Forum Moderators: coopster

Message Too Old, No Replies

php5 - dom xml question

how do i get a tags name?

         

sneaks

6:56 pm on Sep 7, 2006 (gmt 0)

10+ Year Member



looping through an xml document and would like to know, how do i get the current node's tag name?

furhtermore is the follwoing a proper method to go about determining if the xml_text_node actually contains data and not white space?


if ($child -> nodeType == XML_TEXT_NODE)
{
if (trim($child -> textContent))
{
$output = '<div class="currentTagName">' . $child -> textContent . '</div>' . "\n";
print $output;
}
}

thanks!
jd

coopster

7:55 pm on Sep 7, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I think you are looking for this ... DomNode->node_name [php.net] ... if you are using the DOM_XML functions.


is the follwoing a proper method to go about determining if the xml_text_node actually contains data and not white space

You mean by trimming it first? Yes.

sneaks

8:43 pm on Sep 7, 2006 (gmt 0)

10+ Year Member



how about using DOM not DOM-XML? (php5)

thx

coopster

10:07 pm on Sep 7, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Whoops, sorry about that, too quick on the link. Here you go, the methods are listed here:
DOM Functions [php.net]

sneaks

2:53 pm on Sep 8, 2006 (gmt 0)

10+ Year Member



hi coopster, thanks for the link, but i have pored over that page countless times... not asking you to write my code but i cant find it in the dom reference and of course when i google i get a ton of references for getElementsByTagName()

with attributes you can go:

$attribute -> name

i want something like $element -> name

sneaks

2:58 pm on Sep 8, 2006 (gmt 0)

10+ Year Member



nevermind, i got it...

$child -> parentNode -> nodeName

before node name was giving me the id#...

thx

jd