troubleshooting Question

Data.DataSet.ReadXml not returning all records on my XML file

Avatar of ClassicCPLus
ClassicCPLus asked on
.NET ProgrammingC#Visual Basic.NET
3 Comments1 Solution348 ViewsLast Modified:
I am only getting one record:
Question: How do you get all the records?
Sub Question: Is there a better way to approach loading a table in the dataset?
Here is my code:
I want to populate a dataset from an xml file that looks like this: 
 
<?xml version="1.0" encoding="utf-8" ?>
<NewDataset xmlns="http://tempuri.org/TransactionCodes.xsd">
     <Transaction> 
      <Code>DPO</Code>
      <Value>DPO - EXTERNAL VENDOR/EMPLOYEE REIMBURSEMENT</Value>
    </Transaction>
    <Transaction>
      <Code>DPO</Code>
      <Value>DPO - INTERDEPARMENTAL</Value>
    </Transaction>
    <Transaction>
      <Code>AD</Code>
      <Value>AD - CHECK</Value>
    </Transaction>
    <Transaction>
      <Code>CR</Code>
      <Value>CR - CASH RECEIPT</Value>
    </Transaction>
    <Transaction>
      <Code>CX</Code>
      <Value>CX - CANCELLED CHECK</Value>
    </Transaction>
    <Transaction>
      <Code>EB</Code>
      <Value>EB - EXPENSE BUDGET</Value>
    </Transaction>
    <Transaction>
      <Code>ET</Code>
      <Value>ET - EXPENSE BUDGET TRANSFER - CUFS</Value>
    </Transaction>  
    <Transaction>
      <Code>IN</Code>
      <Value>IN - INVOICE EXTERNAL BILLING</Value>
     </Transaction>  
    <Transaction>
      <Code>IV</Code>
      <Value>IV - INTRA INSTITUTION VOUCHER(REVENUE)</Value>
    </Transaction>
     <Transaction>
       <Code>IX</Code>
       <Value>IX - INTRA INSTITUTION VOUCHER(EXPENSE)</Value>
   </Transaction>
    <Transaction>
      <Code>JV</Code>
      <Value>JV - JOURNAL VOUCHER</Value>
   </Transaction>
   <Transaction>
     <Code>MW</Code>
     <Value>MW - MANUAL WARRANT</Value>
   </Transaction>
    <Transaction>
      <Code>PC</Code>
      <Value>PC - PURCHASE ORDER COMMODITY</Value>
    </Transaction>
    <Transaction>
      <Code>PO</Code>
      <Value>PO - NON-COMMODITY PURCHASE ORDER - ADVANTAGE</Value>
    </Transaction>
    <Transaction>
      <Code>PV</Code>
      <Value>PV - PAYMENT VOUCHER</Value>
    </Transaction>
    <Transaction>
      <Code>RB</Code>
      <Value>RB - REVENUE BUDGET</Value>
    </Transaction> 
    <Transaction>
      <Code>RQ</Code>
      <Value>RQ - REQUISITION</Value>
    </Transaction> 
    <Transaction>
      <Code>RX</Code>
      <Value>RX - REQUISITION COMMODITY</Value>
    </Transaction>  
    <Transaction>
      <Code>SC</Code>
      <Value>SC - NON-COMMODITY PURCHASE ORDER - ADVANTAGE</Value>
    </Transaction>
    <Transaction>
      <Code>TA</Code>
      <Value>TA - TRAVEL ADVANCE CUFS</Value>
    </Transaction>
    <Transaction>
      <Code>TB</Code>
      <Value>TB - EXPENSE BUDGET TRANSFER - ADVANTAGE</Value>
    </Transaction>
    <Transaction>
      <Code>TC</Code>
      <Value>TC - TRAVEL CHECK</Value>
    </Transaction>
      <Code>TE</Code>
      <Value>TE - TRAVEL ADVANCE -ADVANTAGE</Value>
    <Transaction>
      <Code>TP</Code>
      <Value>TP - TRAVEL PAYMENT</Value>
    </Transaction> 
    <Transaction>
      <Code>TV</Code>
      <Value>TV - TRANSFER VOUCHER</Value>
    </Transaction>  
   
</NewDataset>
            
The schema looks like this:
 
 
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://tempuri.org/TransactionCodes.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="NewDataset">
    <xs:complexType>
      <xs:sequence>
        <xs:choice maxOccurs="unbounded">
          <xs:element maxOccurs="unbounded" name="Transaction">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="Code" type="xs:string" />
                <xs:element name="Value" type="xs:string" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>
          <xs:element name="Code" type="xs:string" />
          <xs:element name="Value" type="xs:string" />
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
 
 
Here is my code:
        Dim ds As New Data.DataSet()
 
        Dim mypath As String = Server.MapPath("TransactionCodes.xml") 'think do not need this line 
        ds.ReadXml((Server.MapPath("TransactionCodes.xml")))
        Dim myView As Data.DataView
        myView = ds.Tables(0).DefaultView
        Me.GridView1.DataSource = ds
        Me.GridView1.DataBind()
 
I am only getting one record:
NewDataset_Id Code Value 
0 	     TE   TE - TRAVEL ADVANCE -ADVANTAGE
ASKER CERTIFIED SOLUTION
Wayne Taylor (webtubbs)

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros