Jump to content

Grabbing Unique Values Within An Xml File


awitt

Recommended Posts

Hey guys, I need to pull out all elements of data, within an XML, that are unique. Specifically, it's an XML full of school closings around the state. The problem is, sometimes there are duplicate records in the XML. Every record has an id attribute, and even those are the same for the duplicate records. I want to prove/disprove uniqueness using those ids associated with each element. Here's a sample of the XML file:

<closings> 	<county name="Adams"> 		<announcement id="1" onn="1" wbns="0"> 			<location>Ohio Valley Local Schools</location> 			<status>Closed</status> 			<source>172.19.16.33</source> 			<creationtime>Jan 28 2009 05:02AM</creationtime> 			<expiretime>Jan 28 2009 01:00PM</expiretime> 		</announcement> 		<announcement id="2443" onn="1" wbns="0"> 			<location>Snow Emergency</location> 			<status>Level 3 Snow Emergency</status> 			<source>172.19.16.33</source> 			<creationtime>Jan 28 2009 09:19AM</creationtime> 			<expiretime>Jan 28 2009 07:00PM</expiretime> 		</announcement> 	</county>	<county name="Wood"> 		<announcement id="602" onn="1" wbns="0"> 			<location>Bowling Green City Schools</location> 			<status>Closed</status> 			<source>172.19.16.8</source> 			<creationtime>Jan 28 2009 06:50AM</creationtime> 			<expiretime>Jan 28 2009 01:00PM</expiretime> 		</announcement> 		<announcement [b]id="603"[/b] onn="1" wbns="0"> 			<location>Eastwood Local Schools</location> 			<status>Closed</status> 			<source>172.19.16.8</source> 			<creationtime>Jan 28 2009 06:53AM</creationtime> 			<expiretime>Jan 28 2009 01:00PM</expiretime> 		</announcement> 		<announcement [b]id="603"[/b] onn="1" wbns="0"> 			<location>Eastwood Local Schools</location> 			<status>Closed</status> 			<source>172.19.16.8</source> 			<creationtime>Jan 28 2009 06:53AM</creationtime> 			<expiretime>Jan 28 2009 01:00PM</expiretime> 		</announcement> 		<announcement id="604" onn="1" wbns="0"> 			<location>Elmwood Local Schools</location> 			<status>Closed</status> 			<source>172.19.16.8</source> 			<creationtime>Jan 28 2009 06:53AM</creationtime> 			<expiretime>Jan 28 2009 01:00PM</expiretime> 		</announcement>	</county></closings>

And here's what I have for my XSLT (at least as far as going through and selecting nodes):

	   	<xsl:for-each select="closings/county/announcement">	<tr>		<xsl:attribute name="id">row_<xsl:value-of select="./@id" /></xsl:attribute>			<td class="county_row">				<xsl:value-of select="../@name" />			</td>			<td class="location_row">				<xsl:attribute name="id">row_<xsl:value-of select="./@id" />_loc</xsl:attribute>				<xsl:value-of select="location" />			</td>			<td class="status_row">				<xsl:value-of select="status" />			</td>	</tr></xsl:for-each>

Can anyone help me with figuring this out?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...