Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<pre lang="xml"><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<dataroot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <sale>
        <sale_id>10387</sale_id>
        <product_id>CD1003</product_id>
        <sale_date>2012-08-08T00:00:00.000</sale_date>
        <description>APACER DISC STENO CP100 MEDIA COPIER /CD WRITER</description>
        <salesperson_id>SP0002</salesperson_id>
        <category_description>CD-ROM</category_description>
        <sale_price>99</sale_price>
        <sale_qty>1</sale_qty>
    </sale>
    <sale>
        <sale_id>10387</sale_id>
        <product_id>NW1005</product_id>
        <sale_date>2012-08-08T00:00:00.000</sale_date>
        <description>Wise 300TX 10/100 PCI net work card</description>
        <salesperson_id>SP0007</salesperson_id>
        <category_description>NETWORKING HARDWARE</category_description>
        <sale_price>17</sale_price>
        <sale_qty>4</sale_qty>
    </sale>



How do i strip <sale> in it i can do it individually but need to do it and more > then just 2 sale tag

Exmaple

Sale id | Product Id etc..
10387 CD1003
10387 NW1005
Posted

1 solution

XML tag are designed not for stripping them. They allow you to parse XML without any problems with detail of formatting, according strict syntax. By "stripping", you loose essential information on data structure. Please don't tell me you don't need structure. It does not really matter. If you need to read XML, you parse it, nothing else.

With .NET FCL, you are given at least three different approach to parsing. Please see my short review of them:

  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the class System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].


—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900