Home > Ask the Microsoft .Net Development Experts > .NET Development with XML Questions & Answers > Modifying XML rows using XSL sheets
Ask The Win Development Expert: Questions & Answers
EMAIL THIS

Modifying XML rows using XSL sheets

Daniel Cazzulino EXPERT RESPONSE FROM: Daniel Cazzulino

Pose a Question
Other Win Development Categories
Meet all Win Development Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 01 October 2004
Can you explain how to select and modify or delete a row in an XML file using XSL sheets?

>
The way you do it is by having an XSLT that selectively copies to the target output. Here's one such file:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/ | @* | node()">
    <xsl:if test="not(local-name(.)='Customer' and @Id='02')"> 
      <xsl:copy>
        <xsl:apply-templates select="@* | node()" />
      </xsl:copy>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>
Look at the <xsl:if> element, that tests that the current node is not a Customer with an Id attribute of "2", and in that case, it performs the copy.

For a source file like the following:

<?xml version="1.0" encoding="utf-8" ?> 
<Root>
  <Customer Id="01" />
  <Customer Id="02" />
</Root>
You'd get the following output:
<?xml version="1.0" encoding="utf-8" ?> 
<Root>
  <Customer Id="01" />
</Root>


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
.NET Development with XML
Generating Access data as XML for HTML publishing
Editing datagrids, take two
Creating applications to access data via mobile phones
Is it possible to schedule SQLs written for a paradox database?
Questions regarding XML for a decision making tool
Extracting data from Word 6 to populate database
How can I make a connection to a Paradox password protected database?
I have an Access Database that I want to display in a Listview.
Problem with Paradox Connection String
Need an ASP.NET page with a text box and submit button to pull records

XML and Data
Generating Access data as XML for HTML publishing
Editing datagrids, take two
Creating applications to access data via mobile phones
Is it possible to schedule SQLs written for a paradox database?
Questions regarding XML for a decision making tool
Extracting data from Word 6 to populate database
How can I make a connection to a Paradox password protected database?
I have an Access Database that I want to display in a Listview.
Problem with Paradox Connection String
Need an ASP.NET page with a text box and submit button to pull records

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Windows Development - White Papers, News and Expert Advice
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts