Forum Moderators: open

Message Too Old, No Replies

Removing elements from an XML File

         

tjhorne

5:32 pm on Dec 21, 2005 (gmt 0)

10+ Year Member



I have an xml file, see below. I'd like to not display the line that shows index for it's item kind, is this possible with XSL? If so, can you give me an example. Thanks!

<Alert Document_Name="Alerts" Document_Description="" Document_Version="1" Document_Time="19&#47;12&#47;2005 09:51:01" Document_Generator="D:&#92;Program Files&#92;performancesoft&#92;pbviews&#92;pbvcon.exe">
<Item Kind="Alert" Title="Missing Data">
<From>
<User Name="P: MMaris" Email="mmaris@example.com"/>
</From>
<To>
<User Name="P: DHylton" Email="dhylton@example.org"/>
</To>
<Item Kind="Section" Title="P: [ADMIN] Missing Data - Amherst-Nelson">
<Item Kind="Comparison" Title="Actual vs. Target"/>
<Item Kind="Period" Title="2006/12"/>
<Item Kind="Measure (Location)" Title="P: 06 # Experience Initiatives (Amherst-Nelson)">
<Item Kind="Index" Title="--"/>
</Item>
</Item>
</Item>

[edited by: tedster at 7:12 am (utc) on Dec. 23, 2005]
[edit reason] use "example", not real emails [/edit]

tjhorne

8:02 pm on Dec 28, 2005 (gmt 0)

10+ Year Member



Can someone please take a look at this and let me know if you have any ideas?

Thanks!

choster

10:35 pm on Dec 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you're processing on <Item>, you should be able to exclude those of Kind="Index" from being processed by adding a predicate:

<xsl:template match="Item[@Kind!= 'Index']">
...
</xsl:template>

tjhorne

2:01 pm on Dec 30, 2005 (gmt 0)

10+ Year Member



If you look a little closer at the <Item Kind="Index"> line it's wrapped inside another <Item>, would your suggestion still work?

Thanks,

Todd H.

choster

5:39 pm on Dec 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It depends how your XSLT is set up. In any case, the key here is using the right XPath. Here are some sites which you may find useful:

[w3schools.com...] (tutorial and reference)
[mulberrytech.com...] (syntax quick reference)
[xml.com...] (links to various text excerpts)
[topxml.com...]