Welcome to WebmasterWorld Guest from 220.127.116.11 , register , free tools , login , search , subscribe , help , library , announcements , recent posts , open posts Subscribe and Support WebmasterWorld
XSL "attributes" riderdan msg:4126381 9:04 pm on May 3, 2010 (gmt 0) I have a problem that I can't quite solve, despite diligent digging via google, the W3C, and here on the forums. I have an XML file that consists of todo items. Each item contains "attributes" that have a name, type, and value. I'm trying to get a sub-set of this information out so that I can display it on a Web page for tracking them. The closest I've gotten so far is a stylesheet that displays ALL the attributes--but I really only want the datedue and title. Here's a snippet of the XML: <object type="TODO" id="1"> <attribute name="datecompleted" type="date">292818951.40109300613403320312</attribute> <attribute name="datedue" type="date">292748400.00000000000000000000</attribute> <attribute name="title" type="string">Do something</attribute> <attribute name="identifier" type="string">C6F2D32C-0A5A</attribute> </object> Here's my utterly failed XSLT: <xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match="/TODO/attribute"> <xsl:value-of select="name()"/> </xsl:template> </xsl:stylesheet> I can't for the life of me figure out how to get just the two types of attributes (name="title" and name="datedue") out Help! :-)
httpwebwitch msg:4127577 5:35 pm on May 5, 2010 (gmt 0)
Welcome to WebmasterWorld! learn about XPath Predicates [ w3schools.com]. e.g.: //object/attribute[@name='datedue']
riderdan msg:4127663 7:39 pm on May 5, 2010 (gmt 0)
Thanks, that's put me on the right path :-) httpwebwitch msg:4128524 12:25 am on May 7, 2010 (gmt 0)
<pun>you mean, the right XPath?</pun> heh heh httpwebwitch msg:4128527 12:27 am on May 7, 2010 (gmt 0)
I apologize, that was uncalled for. I'm such a nerd...