elwood00 Posted December 8, 2011 Share Posted December 8, 2011 so I have gone through the whole XSLT course online and I thought I had a decent handle on the concept. So armed with that newbie enthusiam, I opened the XML file to design an XSLT so I can get the data we need into our filemaker database.... but when i opened the 96kb monster, I realized how way over my head I was in..... I need some guidance. Unfortunately the XML comes from our client and there is nothing we can change on it, so I have to figure it out somehow and I have to figure it out fast... Here is what I am looking at (or at least a small portion of the relevant part of the file): <?xml version="1.0"?><SITE-INSPECTION isOffline="true" uid="0" nextUid="6217" minorVersion="0" majorVersion="5"><ASSETS uid="482"><CLASS uid="483" name="SiteDetail"><INSTANCES uid="735"><INSTANCE uid="736" remove="0" countryId="USA" busUnit="TEST" structureId="A"><FIELDS uid="737"><FIELD uid="964" name="structureDetails" class="Collection" of="InspectionDetail"><INSTANCES uid="965"><INSTANCE uid="966" remove="0"><FIELDS uid="967"><FIELD uid="968" ovalue="" screenID="" error="none" value="GENERIC" name="MFG"/><FIELD uid="969" ovalue="7002056" screenID="" error="none" value="7002056" name="ModelNr"/></FIELDS></INSTANCE>[more instances]</FIELD>[more fields]</FIELDS></INSTANCE>[more instances]</INSTANCES></CLASS>[more classes]</ASSETS></SITE-INSPECTION> It was all so logical in my <customer><firstname>Joe</firstname></customer> world..... but here i am lost. I basically need to get to the values of the fields (uid 968 and 969), unfortunately, they are not 968 and 969 in every xml file we receive, so that is not helpful. Any pointers would be greatly appreciated....thanks Link to comment Share on other sites More sharing options...
Martin Honnen Posted December 9, 2011 Share Posted December 9, 2011 The "FIELD" elements have attributes named 'uid' so with XPath you need "@uid" to access such an attribute (or the longer "attribute::uid" if you really want to write verbose code).So all you need is e.g. <xsl:template match="FIELD"> <xsl:value-of select="@uid"/></xsl:template> Link to comment Share on other sites More sharing options...
elwood00 Posted December 10, 2011 Author Share Posted December 10, 2011 The "FIELD" elements have attributes named 'uid' so with XPath you need "@uid" to access such an attribute (or the longer "attribute::uid" if you really want to write verbose code).So all you need is e.g.<xsl:template match="FIELD"> <xsl:value-of select="@uid"/></xsl:template> Thanks - a big step forward - I get some data into filemaker now - of course not the stuff I need. I guess, I was not specific enough. Basically where I indicated [more instances] - those are more instances of the same type, namely more devices, where we need to capture the MFG and the ModelNr. So I have kind of figured out how to get to them with a for-each select, but where I have no idea is, how I say: select the value attribute from each field where the name attribute is ModelNr. and select every value attribute from each field where the name attribute is 'MFG'.... I tried value-of selec="name(antennaId), but get an error that the 'expression does not evaluate to a note-set.' Thanks again for any pointers.... Link to comment Share on other sites More sharing options...
Martin Honnen Posted December 10, 2011 Share Posted December 10, 2011 Try an XPath tutorial, the path //FIELD[@name = 'MFG' or @name = 'ModelNr']/@value selects the value attributes of all FIELD elements where the attribute 'name' is 'MFG' or 'ModelNr'. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.