Page 1 of 1
problem..
Posted: Tue Jan 09, 2007 3:51 pm
by heldopslippers
I hava this XML file
<a name="1">
<b name="2">
</b>
</a>
I would like to get the name from b
I thought this but doesn't work:
<xsl:value-of select="/b/@NAME"/>
I hope someone can help me out
Posted: Tue Jan 09, 2007 6:37 pm
by Radu
Hi,
You have two mistakes in the select.
First of all, everything in XSL (and XML in general) is case sensitive so the attribute name must be written "name" and not "NAME".
Then, if you begin an XPath with a "/" it means it's absolute which in your case is not true.
So the select XPath value should read:
Code: Select all
<xsl:value-of select="/a/b/@name"/>
Regards,
Radu
Posted: Wed Jan 10, 2007 1:54 pm
by heldopslippers
THANXS !!!
Posted: Wed Jan 10, 2007 2:33 pm
by heldopslippers
I am sorry...but welll I think my example wasn't good enough ....
this is my new example:
Code: Select all
<FMPXMLRESULT xmlns="http://www.filenaker.com/fmpxmlresult">
<DATABASE NAME="filemaker" />
</FMPXMLRESULT>
well ehm my exmaple wasn't good enough I think so sorry... I tryed this:
Code: Select all
<xsl:value-of select="/FMPXMLRESULT/DATABASE/@NAME" />
I hope somebody can hellp me
(and for radu it works on my first example but not this one)
gr "heldopslippers"
[/code]
Posted: Wed Jan 10, 2007 3:02 pm
by Radu
Hi,
The difference is that all the elements in your second XML fragment are in the "
http://www.filenaker.com/fmpxmlresult" namespace so one way to access the attribute value is to bind the namespace to a prefix and use the prefix in the XPath like:
Code: Select all
<xsl:value-of select="/FS:FMPXMLRESULT/FS:DATABASE/@NAME" xmlns:FS="http://www.filenaker.com/fmpxmlresult"/>
I recommend reading this tutorial
http://www.zvon.org/xxl/XSLTutorial/Output/index.html about stylesheets.
We also have more tutorial links here:
http://www.oxygenxml.com/tutorials.html
Regards,
Radu
Posted: Wed Jan 10, 2007 3:11 pm
by heldopslippers
I works !! thank you..... and I wil read the tutorials
gr "heldopslippers"