Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search XML file

Status
Not open for further replies.

pancake

Programmer
Aug 21, 2001
88
GB
Please help, I am fairly new to XML. I would like to create a simple drop down box in a html page that filters by YearGroup (for example year 10) and will show results of that year group only, although my XML file has lots of year groups in it. Below is an example of the data.

Is this possible?

Thanks in advance



<?xml version="1.0" standalone="yes" ?>
- <SuperStarReport>
- <Record>
<FullName>Joe Bloggs</FullName>
<YearGroup>Year 10</YearGroup>
<Total>0</Total>
<Total1>0</Total1>
</Record>
- <Record>
<FullName>Fred Bloggs</FullName>
<YearGroup>Year 9</YearGroup>
<Total>0</Total>
<Total1>0</Total1>
</Record>
 
Well to build up a drop down list via an XML transform you could use something along the lines of

Code:
<select name="Students">
 <xsl:for-each select="SuperstarReport/Record">
    <xsl:if test="YearGroup = 'Year 10'">
      <option value='<xsl:value-of select="FullName"/>'>'<xsl:value-of select="FullName"/>'</option>
    </xsl:if>
    </xsl:for-each>
</select>

caveat. All the above is off the top of my head. Id suggest you start somewhere liek w3schools.com and read about xslt and xpath

K
 
Thanks for the suggestion. I will have a look at this early next week, and post the code if I manage to crack it !

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top