Thanks a lot. Sorry but 5 minutes after sending this email i figured it out
myself. I didn't know how to answer my own message because i didn't get my
own message... Anyway, this worked for me:
xsl:for-each select=//elementA | //elementB
xsl:value-of select=name(.) /
/xsl:for-each
Hope this helps someone else...
Thanks again.
Tim
Tim-Hinnerk Heuer
http://www.ihostnz.com
Bill Watterson - There is not enough time to do all the nothing we want to
do.
2009/2/21 Boyd, Todd M. tmbo...@ccis.edu
-Original Message-
From: th.he...@gmail.com [mailto:th.he...@gmail.com] On Behalf Of
German Geek
Sent: Friday, February 20, 2009 9:18 AM
To: PHP General list
Subject: [PHP] XML - XSLT transformation using XSLTProcessor class
Hi All,
We are trying to import some xml data into the database. My idea was to
make
an xslt and then transform the xml to php code which generates the
queries
necessary and then gets evaled as php code for the actual import...
Anyway, i got it working (mostly)!
But i need to get the current element name with x-path. So i have the
following:
rootEl
elementAchildOfAsome data 1/childOfA/elementA
elementBchildOfBsome data 2/childOfB/elementB
elementBchildOfBsome data 3/childOfB/elementB
elementAchildOfAsome data 4/childOfA/elementA
elementAchildOfAsome data 5/childOfA/elementA
/rootEl
xsl:for-each select=//elementA | //elementB
// xsl:value-of select=childOfA / WORKS and gives the value of
childOfA (e.g. some data 1)
//... the php code...
/xsl:for-each
In the php code, I need to get the element tag name of the current
element,
so either elementA or elementB. How can i get that in an x-path
expression?
I know, this is not strictly a php question, but since the project is
in php
and this list has a very good response rate, i decided to ask here. I
already looked on the web for hours, but maybe i just don't have the
right
keywords.
Please help. Thanks.
I believe the name() XPath function is what you are looking for. It's been
a while since I've worked with XPath query strings, but I believe
.[name()] will get you the current element's tag name. Keep in mind: I'm
not sure if this works with namespaced tags (like namespace:tagname /),
but I have not tested this to be sure.
HTH,
// Todd