Jump to content

Grabbing Unique Values Within An Xml File


awitt
 Share

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...