I have a strange issue here... I have this webservice that generate its result as xml. I can see I get the data I want, but I can't get my xslt to dig into it!?
Just a guess but I think by using double / in {$cheap1//BookingUrl} means that BookingUrl is directly under the root node, which it isn't. So I think you could either use a single / like {$cheap1/BookingUrl} or write the full path like {$cheap1/FlightSuggestionDC/BookingUrl}
I have tried you suggestion in multiple ways, but no sign of success. According to my understading of XSLT double slash "//" tells to go deeper into the dataset find whatever comes after //. (See here: http://w3schools.com/xpath/xpath_syntax.asp)
Yes, it is case sensitive - but I have copied the tag names from the source code, so I'm pretty sure I have it currect. To be honest I already have tried with lowercase etc.
The copy-of methot I have also tried. The "data from the webservice"-code i posted in my question is from a copy-of the $cheap1.
Welcome to the namespaces section of the XSLT manual :-)
The XML you're receiving has a default namespace associated with it (the xmlns="http://webservices.domain.se/partners/" part) which means that every element in the file is "scoped" to that namespace; In order for your XSLT file to be able to select those elements, it needs to do two things:
Define a prefix and associate it with the namespace-URI (case-sensitive!) of the XML file
Use that prefix to select the elements
First of all, make sure that you did the copy-of inside a <textarea> element in the Visualizer (otherwise, it lowercases all the tags - and your XML looks suspiciously like it was mangled with by the visualizer :-)
Now, define the namespace (I guess you changed it for obvious reasons, so I'm using the one you supplied):
How to get xml data from webservice
Hi all - thanks for a great CG11!
I have a strange issue here... I have this webservice that generate its result as xml. I can see I get the data I want, but I can't get my xslt to dig into it!?
My basic xslt:
The data from the webservice:
Please help
Hi Kasper,
Just a guess but I think by using double / in {$cheap1//BookingUrl} means that BookingUrl is directly under the root node, which it isn't. So I think you could either use a single / like {$cheap1/BookingUrl} or write the full path like {$cheap1/FlightSuggestionDC/BookingUrl}
Ben
Hi Ben
I have tried you suggestion in multiple ways, but no sign of success. According to my understading of XSLT double slash "//" tells to go deeper into the dataset find whatever comes after //. (See here: http://w3schools.com/xpath/xpath_syntax.asp)
Is it case sensitive i.e. $cheap1/BookingUrl vs $cheap1/bookingurl
Also try doinf <xsl:copy select="$cheap1" /> to inspect the XML to see if there are clues there.
Hi Poul,
Yes, it is case sensitive - but I have copied the tag names from the source code, so I'm pretty sure I have it currect. To be honest I already have tried with lowercase etc.
The copy-of methot I have also tried. The "data from the webservice"-code i posted in my question is from a copy-of the $cheap1.
Hi Kasper,
Welcome to the namespaces section of the XSLT manual :-)
The XML you're receiving has a default namespace associated with it (the xmlns="http://webservices.domain.se/partners/" part) which means that every element in the file is "scoped" to that namespace; In order for your XSLT file to be able to select those elements, it needs to do two things:
First of all, make sure that you did the copy-of inside a <textarea> element in the Visualizer (otherwise, it lowercases all the tags - and your XML looks suspiciously like it was mangled with by the visualizer :-)
Now, define the namespace (I guess you changed it for obvious reasons, so I'm using the one you supplied):
(I'm using "data" as the prefix, but you can use pretty much whatever you want)
Then, use the prefix when accessing data from the document:
Yay - done!
/Chriztian
Thanks to Chriztian - the xslt guru of all xslt gurus. It works like charm!
Thanks for very valuable information!
is working on a reply...