jbru Posted August 29, 2012 Share Posted August 29, 2012 Hi, So I'm hoping to get some pointers on identifying namespaces and data contained within them. I have the task of transforming some (to my mind at least) unusual xml and I've not been able to successfully navigate it. Here's an example of the xml: <Report><ReportHost name="SampleHostName"><HostProperties><tag name="End_Time">Fri Jul 30 16:14:56 2010</tag><tag name="mac-address">00:00:00:00:00:01</tag><tag name="os_name">Microsoft Windows</tag><tag name="hostname">TestHostname</tag><tag name="Start_Time">Fri Jul 30 16:13:51 2010</tag></HostProperties>...</ReportHost>...</Report> And here is relevant portion of the XSLT that I'm trying to use to assign "TestHostname" to an XSLT variable: <xsl:for-each select="Report/ReportHost"> <xsl:variable name="hostname" select="HostProperties/tag"/> Running this, the variable "hostname" is assigned all the information (Fri Jul 30 16:14:56 2010 00:00:00:00:00:01 Microsoft Windows TestHostname Fri Jul 30 16:13:51 2010). If I run it with the select expression "HostProperties/hostname" it returns nothing. How can I assign the xslt variable "hostname" the relevant data that is held in <tag name="hostname">TestHostname</tag> ? Unfortunately I haven't been able to find any information quite like this in any of the documentation or trainings I've seen. Link to comment Share on other sites More sharing options...
jbru Posted August 29, 2012 Author Share Posted August 29, 2012 Okay, I think I solved it myself after a lot of trial and error. This seems to have done the trick: <xsl:variable name="hostname" select="HostProperties/tag[@name='hostname']"/> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now