converting xml to text file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • devquest
    New Member
    • Dec 2009
    • 12

    converting xml to text file

    I have an xml file, and I need to convert it into a text file.
    xml:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <po-response xmlns="http://seller.marketpl ace.sears.com/oms/v1" xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocat ion="https://seller.marketpl ace.sears.com//SellerPortal/s/schema/oms/purchaseorder-v1.xsd">
    - <purchase-order>
    <po-number>2180031</po-number>
    <po-date>2009-12-27</po-date>
    <expected-ship-date>2010-01-01</expected-ship-date>
    - <shipping-detail>
    <ship-to-name>WILLIAM BENTLEY</ship-to-name>
    <city>INDIANAPO LIS</city>
    <state>IN</state>
    <zipcode>4622 1</zipcode>
    <shipping-method>Ground</shipping-method>
    </shipping-detail>
    <customer-name>WILLIAM BENTLEY</customer-name>
    - <po-line>
    - <po-line-header>
    <line-number>2</line-number>
    <item-id>PRP2008</item-id>
    <item-name>Kicker DSM60 6.5 Inch Coaxial 2-Way Speakers</item-name>
    <item-sell-price>3900</item-sell-price>
    <order-quantity>2</order-quantity>
    </po-line-header>
    - <po-line-detail>
    <po-line-status>SHIPPED</po-line-status>
    <quantity>2</quantity>
    </po-line-detail>
    </po-line>
    - <po-line>
    - <po-line-header>
    <line-number>1</line-number>
    <item-id>PRP2047</item-id>
    <item-name>Kenwood KDC-138 AM/FM/CD-Receiver</item-name>
    <item-sell-price>9437</item-sell-price>
    <order-quantity>1</order-quantity>
    </po-line-header>
    - <po-line-detail>
    <po-line-status>SHIPPED</po-line-status>
    <quantity>1</quantity>
    </po-line-detail>
    </po-line>
    <order-subtotal>172.37 </order-subtotal>
    <sales-tax>13.54</sales-tax>
    <shipping-fees>20.95</shipping-fees>
    <order-total>206.86</order-total>
    <po-status>CLOSED</po-status>
    </purchase-order>

    How can I convert this to a text file containing most of these fields?
    Thank you.
  • ThatThatGuy
    Recognized Expert Contributor
    • Jul 2009
    • 453

    #2
    you can use XmlReader or XmlDocument classes of .net to retrieve data out of any node... or to parse the whole file...

    it would be messy afterwards though...

    Comment

    • devquest
      New Member
      • Dec 2009
      • 12

      #3
      ok. thank you. I figured out how to convert it to a text document. I have a question. Some of the purchase orders have many addresses returned
      example:
      <purchase-order>
      <po-number>111111</po-number>
      <po-date>2010-01-31</po-date>
      <expected-ship-date>2010-02-05</expected-ship-date>
      - <shipping-detail>
      <ship-to-name>John Doe</ship-to-name>
      <address>addres s 1</address>
      <address>addres s 2</address>
      <address>addres s 3</address>
      <address>addres s 4</address>
      <address>addres s 5</address>
      <city>NY</city>
      <state>NY</state>
      <zipcode>1111 1</zipcode>
      <shipping-method>USPS</shipping-method>
      </shipping-detail>
      <customer-name>John Doe</customer-name>
      - <po-line>
      - <po-line-header>
      <line-number>1</line-number>
      <item-id>Ab123</item-id>
      <item-name>Item Name</item-name>
      <item-sell-price>47.25</item-sell-price>
      <order-quantity>1</order-quantity>
      </po-line-header>
      - <po-line-detail>
      <po-line-status>NEW</po-line-status>
      <quantity>1</quantity>
      </po-line-detail>
      </po-line>
      <order-subtotal>47.25</order-subtotal>
      <sales-tax>0.0</sales-tax>
      <shipping-fees>6.25</shipping-fees>
      <order-total>53.5</order-total>
      <po-status>New</po-status>
      </purchase-order>
      I only want 3 addresses. If there are more, I want to remove the rest of the addresses. How can this be done in vb.net?
      Thank you.

      Comment

      Working...