CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Parse XML

  1. #1
    Join Date
    May 2012
    Posts
    2

    Parse XML

    I am struck with parsing this xml File can any one help me to parse this.

    - <site>
    - <transactionList>
    - <transaction uniqueId="14141414" type="debit" baseType="debit">
    <description>CHECK # 998</description>
    <checkNumber>998</checkNumber>
    <amount curCode="USD">59.00</amount>
    <link>link</link>
    <category>category</category>
    <transDate localFormat="MM/dd/yy">2005-07-16T00:00:00</transDate>
    </transaction>
    - <transaction uniqueId="1111111" type="deposit" baseType="credit">
    <description>DESC</description>
    <link>http://www.altova.com</link>
    <amount curCode="USD">343465.00</amount>
    <transDate localFormat="yyyy-MM-dd">2005-07-16T00:00:00</transDate>
    <postDate localFormat="yyyy-MM-dd">2005-07-16T00:00:00</postDate>
    <checkNumber>DAG-333</checkNumber>
    <category categoryId="333">other</category>
    </transaction>
    </transactionList>
    </site>


    Following is the error I received while parsing this XML File

    Data at the root level is invalid. Line 1, position 1.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Parse XML

    It helps nothing you just give us the XML code. We need your VB code as well, because your error may be in there..

  3. #3
    Join Date
    May 2012
    Posts
    2

    Re: Parse XML

    Thanks a lot for your reply. I have chosen SSIS (ETL tool) to parse XML file.

  4. #4
    Join Date
    Jan 2009
    Posts
    596

    Re: Parse XML

    Why are these '-' characters in the xml?
    Code:
    - <site>
    - <transactionList>
    - <transaction uniqueId="14141414" type="debit" baseType="debit">
      <description>CHECK # 998</description> 
      <checkNumber>998</checkNumber> 
      <amount curCode="USD">59.00</amount> 
      <link>link</link> 
      <category>category</category> 
      <transDate localFormat="MM/dd/yy">2005-07-16T00:00:00</transDate> 
      </transaction>
    - <transaction uniqueId="1111111" type="deposit" baseType="credit">
      <description>DESC</description> 
      <link>http://www.altova.com</link> 
      <amount curCode="USD">343465.00</amount> 
      <transDate localFormat="yyyy-MM-dd">2005-07-16T00:00:00</transDate> 
      <postDate localFormat="yyyy-MM-dd">2005-07-16T00:00:00</postDate> 
      <checkNumber>DAG-333</checkNumber> 
      <category categoryId="333">other</category> 
      </transaction>
      </transactionList>
      </site>

  5. #5
    Join Date
    Apr 2012
    Posts
    43

    Re: Parse XML

    The XmlDocument class can be used to parse XML data.

  6. #6
    Join Date
    May 2012
    Location
    Bonn, Germany
    Posts
    43

    Re: Parse XML

    I too think those dashes are the problem.
    They would be interpreted as "data" since they are not tags. And the first thing in this document is a dash.
    I think they come from copying a XML file when opening it in Internet Explorer (the +/- icons are for unfolding nodes).

  7. #7
    Join Date
    Jan 2009
    Posts
    596

    Re: Parse XML

    Quote Originally Posted by TomasRiker View Post
    I think they come from copying a XML file when opening it in Internet Explorer (the +/- icons are for unfolding nodes).
    Yes, this happens when opening in Firefox also. There is a dash in front of each tag which spans multiple lines.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured