Solved

xml xsl and dataset

Posted on 2004-09-29
22
623 Views
Last Modified: 2013-11-19
Hi

I have the following xml and schema(schema may be wrong).I want to populate dataset with table name as "main" and need to add the schema for the table.

When we creating dataset from xml what is exact structure  and schema structure.

Because i want to use dataview sorting so i need to add  datatype to the table and need to populate the records.

XML:

<main>
      <SummaryInformation >
                        <PickupDate value="10/29/2001"></PickupDate>
                        <PickUpRecord  value="6481802191"></PickUpRecord>      
                        <NoOfPackages value="78"></NoOfPackages>
                        <PublishedCharge value="955.75"></PublishedCharge>
                        <IncentiveCredit value="-231.08"></IncentiveCredit>
                        <BilledCharges value="724.67"></BilledCharges>
                  </SummaryInformation>
                  <SummaryInformation >
                        <PickupDate value="10/29/2001"></PickupDate>
                        <PickUpRecord  value="6481802191"></PickUpRecord>      
                        <NoOfPackages value="78"></NoOfPackages>
                        <PublishedCharge value="955.75"></PublishedCharge>
                        <IncentiveCredit value="-231.08"></IncentiveCredit>
                        <BilledCharges value="724.67"></BilledCharges>
                  </SummaryInformation>
                  <SummaryInformation >
                        <PickupDate value="10/29/2001"></PickupDate>
                        <PickUpRecord  value="6481802191"></PickUpRecord>      
                        <NoOfPackages value="78"></NoOfPackages>
                        <PublishedCharge value="955.75"></PublishedCharge>
                        <IncentiveCredit value="-231.08"></IncentiveCredit>
                        <BilledCharges value="724.67"></BilledCharges>
                  </SummaryInformation>
                  <SummaryInformation >
                        <PickupDate value="10/29/2001"></PickupDate>
                        <PickUpRecord  value="6481802191"></PickUpRecord>      
                        <NoOfPackages value="78"></NoOfPackages>
                        <PublishedCharge value="955.75"></PublishedCharge>
                        <IncentiveCredit value="-231.08"></IncentiveCredit>
                        <BilledCharges value="724.67"></BilledCharges>
                  </SummaryInformation>
</main>

XSD :

<?xml version="1.0" standalone="yes"?>
<xs:schema id="main" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:element name="main" msdata:IsDataSet="true">
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element name="SummaryInformation">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="PickupDate" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="value" type="xs:date" />
                </xs:complexType>
              </xs:element>
              <xs:element name="PickUpRecord" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="value" type="xs:integer" />
                </xs:complexType>
              </xs:element>
              <xs:element name="NoOfPackages" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="value" type="xs:integer" />
                </xs:complexType>
              </xs:element>
              <xs:element name="PublishedCharge" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="value" type="xs:decimal" />
                </xs:complexType>
              </xs:element>
              <xs:element name="IncentiveCredit" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="value" type="xs:decimal" />
                </xs:complexType>
              </xs:element>
              <xs:element name="BilledCharges" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="value" type="xs:decimal" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

Thanks
Ravi
0
Comment
Question by:pprasadravi
  • 10
  • 6
  • 2
  • +1
22 Comments
 
LVL 1

Expert Comment

by:rk_1972
ID: 12181844
DataSets can be populated from the contents of a valid XML file using ReadXml method

for example :

Dim myDataSet as New DataSet()
   
myDataSet.ReadXml(Server.MapPath("main.xml"))
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12181857
' Visual Basic
Dim filePath As String
filePath = "Complete path where you saved the XML file"
dsAuthors.ReadXml(filePath)
With DataGrid1
   .DataSource = dsAuthors
   .DataMember = "authors"
   .CaptionText = .DataMember
End With

Private Sub WriteXmlToFile(thisDataSet As DataSet)
    If thisDataSet Is Nothing Then
        Return
    End If
    ' Create a file name to write to.
    Dim filename As String = "myXmlDoc.xml"
    ' Create the FileStream to write with.
    Dim myFileStream As New System.IO.FileStream _
       (filename, System.IO.FileMode.Create)
    ' Create an XmlTextWriter with the fileStream.
    Dim myXmlWriter As New System.Xml.XmlTextWriter _
       (myFileStream, System.Text.Encoding.Unicode)
    ' Write to the file with the WriteXml method.
    thisDataSet.WriteXml(myXmlWriter)
    myXmlWriter.Close()
End Sub

Regards,

Aeros
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12181861
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("countries.xml"));
 
XmlDataDocument xmlDoc = new XmlDataDocument(ds);
     
XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("/Countries/Country[on=true]");
0
 
LVL 1

Expert Comment

by:rk_1972
ID: 12181880

And you can use ReadXMLSchema to Apply the Schema to the dataSet

Dim myDataSet as New DataSet()
   
myDataSet.ReadXmlSchema(Server.MapPath("main.xml"))
0
 
LVL 3

Expert Comment

by:w_shaila
ID: 12182022
If you want to see what is the defalut Scema,

myDataSet.ReadXml(Server.MapPath("main.xml"))

After that myDataSet.WriteXMLSchema("main.xsd")

you can see what is the XSD the dataset has.
0
 

Author Comment

by:pprasadravi
ID: 12182436
hi
here is another xml document and i am getting the error.

<main>
              <SummaryInformation >
                        <PickupDate>10/29/2001></PickupDate>
                        <PickUpRecord val=6481802191></PickUpRecord>      
                        <NoOfPackages >44</NoOfPackages>
                        <PublishedCharge>955.75</PublishedCharge>
                        <IncentiveCredit>-231.08</IncentiveCredit>
                        <BilledCharges>724.67</BilledCharges>
                  </SummaryInformation>
                  <SummaryInformation >
                        <PickupDate >10/29/2001></PickupDate>
                        <PickUpRecord val=6481802191></PickUpRecord>      
                        <NoOfPackages >44</NoOfPackages>
                        <PublishedCharge>955.75</PublishedCharge>
                        <IncentiveCredit>-231.08</IncentiveCredit>
                        <BilledCharges>724.67</BilledCharges>
                  </SummaryInformation>
                  <SummaryInformation >
                        <PickupDate>10/29/2001</PickupDate>
                        <PickUpRecord val=6481802191></PickUpRecord>      
                        <NoOfPackages >44</NoOfPackages>
                        <PublishedCharge>955.75</PublishedCharge>
                        <IncentiveCredit>-231.08</IncentiveCredit>
                        <BilledCharges>724.67</BilledCharges>
                  </SummaryInformation>
                  <SummaryInformation >
                        <PickupDate>10/29/2001</PickupDate>
                        <PickUpRecord val=6481802191></PickUpRecord>      
                        <NoOfPackages >44</NoOfPackages>
                        <PublishedCharge>955.75</PublishedCharge>
                        <IncentiveCredit>-231.08</IncentiveCredit>
                        <BilledCharges>724.67</BilledCharges>
                  </SummaryInformation>
</main>
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12182482
what is 'the error'?
0
 

Author Comment

by:pprasadravi
ID: 12183602
Error is solved.
Here is schema,xml and code.The problem is  for PickUprecord it is creating anothet table with name PICKUPRECORD and have the element pickupid.for this xml it is creating two tables.
i want to populate all data in on table if it has child elemets like details we can go for another table but attribute value should populate in the same table.
Can anyone tell me what i need to chane in SCHEMA FILE.I can't change the xml structure.
Here is the scheme :

<xs:schema id="main" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
      <xs:element name="main" msdata:IsDataSet="true">
            <xs:complexType>
                  <xs:choice maxOccurs="unbounded">
                        <xs:element name="SummaryInformation">
                              <xs:complexType>
                                    <xs:sequence>
                                          <xs:element name="PickupDate" type="xs:date" minOccurs="0" />
                                          <xs:element name="NoOfPackages" type="xs:integer" minOccurs="0" />
                                          <xs:element name="PublishedCharge" type="xs:decimal" minOccurs="0" />
                                          <xs:element name="IncentiveCredit" type="xs:decimal" minOccurs="0" />
                                          <xs:element name="BilledCharges" type="xs:decimal" minOccurs="0" />
                                          <xs:element name="PickUpRecord" minOccurs="0" maxOccurs="unbounded">
                                          <xs:complexType>
                                                <xs:sequence>
                                                      <xs:element name="Details" type="xs:integer" minOccurs="0" msdata:Ordinal="0" />
                                                </xs:sequence>
                                                <xs:attribute name="Pickupid" type="xs:string" />
                                                </xs:complexType>
                                          </xs:element>
                                    </xs:sequence>
                              </xs:complexType>
                        </xs:element>
                  </xs:choice>
            </xs:complexType>
      </xs:element>
</xs:schema>
Here is xml :

<main>
              <SummaryInformation >
                        <PickupDate>10/29/1845</PickupDate>
                        <PickUpRecord Pickupid="6481802191">
                        <Details>
                        </Details>
                        </PickUpRecord>      
                        <NoOfPackages >44</NoOfPackages>
                        <PublishedCharge>955.75</PublishedCharge>
                        <IncentiveCredit>-231.08</IncentiveCredit>
                        <BilledCharges>724.67</BilledCharges>
                  </SummaryInformation>
                   <SummaryInformation >
                        <PickupDate>10/29/1977</PickupDate>
                        <PickUpRecord Pickupid="6481802191">
                        <Details>
                        </Details>
                        </PickUpRecord>      
                        <NoOfPackages >44</NoOfPackages>
                        <PublishedCharge>955.75</PublishedCharge>
                        <IncentiveCredit>-231.08</IncentiveCredit>
                        <BilledCharges>724.67</BilledCharges>
                  </SummaryInformation>
                   <SummaryInformation >
                        <PickupDate>10/29/2055</PickupDate>
                        <PickUpRecord Pickupid="6481802191">
                        <Details>
                        </Details>
                        </PickUpRecord>      
                        <NoOfPackages >44</NoOfPackages>
                        <PublishedCharge>955.75</PublishedCharge>
                        <IncentiveCredit>-231.08</IncentiveCredit>
                        <BilledCharges>724.67</BilledCharges>
                  </SummaryInformation>
                   <SummaryInformation >
                        <PickupDate>10/29/2033</PickupDate>
                        <PickUpRecord Pickupid="6481802191">
                        <Details>
                        </Details>
                        </PickUpRecord>      
                        <NoOfPackages >44</NoOfPackages>
                        <PublishedCharge>955.75</PublishedCharge>
                        <IncentiveCredit>-231.08</IncentiveCredit>
                        <BilledCharges>724.67</BilledCharges>
                  </SummaryInformation>
                   <SummaryInformation >
                        <PickupDate>10/29/2002</PickupDate>
                        <PickUpRecord Pickupid="6481802191">
                        <Details>
                        </Details>
                        </PickUpRecord>      
                        <NoOfPackages >44</NoOfPackages>
                        <PublishedCharge>955.75</PublishedCharge>
                        <IncentiveCredit>-231.08</IncentiveCredit>
                        <BilledCharges>724.67</BilledCharges>
                  </SummaryInformation>
                   <SummaryInformation >
                        <PickupDate>10/29/2003</PickupDate>
                        <PickUpRecord Pickupid="6481802191">
                        <Details>
                        </Details>
                        </PickUpRecord>      
                        <NoOfPackages >44</NoOfPackages>
                        <PublishedCharge>955.75</PublishedCharge>
                        <IncentiveCredit>-231.08</IncentiveCredit>
                        <BilledCharges>724.67</BilledCharges>
                  </SummaryInformation>
</main>


Here is Code

DataSet xx=new DataSet();
                        xx.ReadXml(Server.MapPath("XMLFile2.xml"));
                        xx.ReadXmlSchema(Server.MapPath("XSDSchema1.xsd"));
                        int count1=xx.Tables[0].Rows.Count;
                        string tablename=xx.Tables[0].TableName;

                        foreach( DataColumn dc in xx.Tables[0].Columns )
                        {
                              Response.Write(dc.ColumnName+" , "+dc.DataType +" ,"+dc.Unique +" ,"+dc.AutoIncrement+" ,"+dc.AllowDBNull );
                              Response.Write("<br>");

                        }
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12189022
So you resolved the issue my friend?

Aeros
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 17

Expert Comment

by:AerosSaga
ID: 12189057
Look into annotation:

Annotations enable you to modify the names of the elements in your typed DataSet without modifying the underlying schema. Modifying the names of the elements in your underlying schema would cause the typed DataSet to refer to objects that do not exist in the data source, as well as losing a reference to the objects that do exist in the data source.

Using annotations, you can customize the names of objects in your typed DataSet with more meaningful names, making code more readable and your typed DataSet easier for clients to use, while leaving underlying schema intact. For example, the following schema element for the Customers table of the Northwind database would result in a DataRow object name of CustomersRow and a DataRowCollection named Customers.

<xs:element name="Customers">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="CustomerID" type="xs:string" minOccurs="0" />
    </xs:sequence>
  </xs:complexType>
</xs:element>
A DataRowCollection name of Customers is meaningful in client code, but a DataRow name of CustomersRow is misleading because it is a single object. Also, in common scenarios, the object would be referred to without the Row identifier and instead would be simply referred to as a Customer object. The solution is to annotate the schema and identify new names for the DataRow and DataRowCollection objects. Following is the annotated version of the previous schema.

<xs:element name="Customers" codegen:typedName="Customer" codegen:typedPlural="Customers">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="CustomerID" type="xs:string" minOccurs="0" />
    </xs:sequence>
  </xs:complexType>
</xs:element>
Specifying a typedName value of Customer will result in a DataRow object name of Customer. Specifying a typedPlural value of Customers preserves the DataRowCollection name of Customers.

The following table shows the annotations available for use.

Annotation Description
typedName Name of the object.
typedPlural Name of a collection of objects.
typedParent Name of the object when referred to in a parent relationship.
typedChildren Name of the method to return objects from a child relationship.
nullValue Value if the underlying value is DBNull. See the following table for nullValue annotations. The default is _throw.

The following table shows the values that can be specified for the nullValue annotation.

nullValue Description
Replacement Value Specifies a value to be returned. The returned value must match the type of the element. For example, use nullValue="0" to return 0 for null integer fields.
_throw Throw an exception. This is the default.
_null Return a null reference or throw an exception if a primitive type is encountered.
_empty For strings, return String.Empty, otherwise return an object created from an empty constructor. If a primitive type is encountered, throw an exception.

The following table shows default values for objects in a typed DataSet and the available annotations.

Object/Method/Event Default Annotation
DataTable TableNameDataTable typedPlural
DataTable Methods NewTableNameRow
AddTableNameRow

DeleteTableNameRow
 typedName
DataRowCollection TableName typedPlural
DataRow TableNameRow typedName
DataColumn DataTable.ColumnNameColumn
DataRow.ColumnName
 typedName
Property PropertyName typedName
Child Accessor GetChildTableNameRows typedChildren
Parent Accessor TableNameRow typedParent
DataSet Events TableNameRowChangeEvent
TableNameRowChangeEventHandler
 typedName

To use typed DataSet annotations, you must include the following xmlns reference in your XML Schema definition language (XSD) schema.

xmlns:codegen="urn:schemas-microsoft-com:xml-msprop"
The following is a sample, annotated schema that exposes the Customers table of the Northwind database with a relation to the Orders table included.

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="CustomerDataSet"
      xmlns:codegen="urn:schemas-microsoft-com:xml-msprop"
      xmlns=""
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:element name="CustomerDataSet" msdata:IsDataSet="true">
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element name="Customers" codegen:typedName="Customer" codegen:typedPlural="Customers">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="CustomerID" codegen:typedName="CustomerID" type="xs:string" minOccurs="0" />
              <xs:element name="CompanyName" codegen:typedName="CompanyName" type="xs:string" minOccurs="0" />
              <xs:element name="Phone" codegen:typedName="Phone" codegen:nullValue="" type="xs:string" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Orders" codegen:typedName="Order" codegen:typedPlural="Orders">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="OrderID" codegen:typedName="OrderID" type="xs:int" minOccurs="0" />
              <xs:element name="CustomerID" codegen:typedName="CustomerID" codegen:nullValue="" type="xs:string" minOccurs="0" />
              <xs:element name="EmployeeID" codegen:typedName="EmployeeID" codegen:nullValue="0" type="xs:int" minOccurs="0" />
              <xs:element name="OrderDate" codegen:typedName="OrderDate" codegen:nullValue="1980-01-01T00:00:00" type="xs:dateTime" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
    <xs:unique name="Constraint1">
      <xs:selector xpath=".//Customers" />
      <xs:field xpath="CustomerID" />
    </xs:unique>
    <xs:keyref name="CustOrders" refer="Constraint1" codegen:typedParent="Customer" codegen:typedChildren="GetOrders">
      <xs:selector xpath=".//Orders" />
      <xs:field xpath="CustomerID" />
    </xs:keyref>
  </xs:element>
</xs:schema>
The following code example uses a strongly typed DataSet created from the sample schema. It uses one DataAdapter to populate the Customers table and another DataAdapter to populate the Orders table. The strongly typed DataSet defines the DataRelations.

[Visual Basic]
Dim nwindConn As SqlConnection = New SqlConnection("Data Source=localhost;Integrated Security=SSPI;" & _
                                                   "Initial Catalog=northwind")
Dim custDA As SqlDataAdapter = New SqlDataAdapter("SELECT CustomerID, CompanyName, Phone FROM Customers", &
                                                  nwindConn)
Dim orderDA As SqlDataAdapter = New SqlDataAdapter("SELECT OrderID, CustomerID, EmployeeID, OrderDate FROM Orders", &
                                                   nwindConn)

' Populate a strongly typed DataSet.
nwindConn.Open()
Dim custDS As CustomerDataSet = New CustomerDataSet()
custDA.Fill(custDS, "Customers")
orderDA.Fill(custDS, "Orders")
nwindConn.Close()

' Add a strongly typed event.
AddHandler custDS.Customers.CustomerChanged, &
           New CustomerDataSet.CustomerChangeEventHandler(AddressOf OnCustomerChanged)

' Add a strongly typed DataRow.
Dim newCust As CustomerDataSet.Customer = custDS.Customers.NewCustomer()
newCust.CustomerID = "NEW01"
newCust.CompanyName = "My New Company"
custDS.Customers.AddCustomer(newCust)

' Navigate the child relation.
Dim customer As CustomerDataSet.Customer
Dim order As CustomerDataSet.Order

For Each customer In custDS.Customers
  Console.WriteLine(customer.CustomerID)
  For Each order In customer.GetOrders()
    Console.WriteLine(vbTab & order.OrderID)
  Next
Next

Private Shared Sub OnCustomerChanged(sender As Object, e As CustomerDataSet.CustomerChangeEvent)

End Sub
[C#]
SqlConnection nwindConn = new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind");
SqlDataAdapter custDA = new SqlDataAdapter("SELECT CustomerID, CompanyName, Phone FROM Customers", nwindConn);
SqlDataAdapter orderDA = new SqlDataAdapter("SELECT OrderID, CustomerID, EmployeeID, OrderDate FROM Orders", nwindConn);

// Populate a strongly typed DataSet.
nwindConn.Open();
CustomerDataSet custDS = new CustomerDataSet();
custDA.Fill(custDS, "Customers");
orderDA.Fill(custDS, "Orders");
nwindConn.Close();

// Add a strongly typed event.
custDS.Customers.CustomerChanged += new
  CustomerDataSet.CustomerChangeEventHandler(OnCustomerChanged);

// Add a strongly typed DataRow.
CustomerDataSet.Customer newCust = custDS.Customers.NewCustomer();
newCust.CustomerID = "NEW01";
newCust.CompanyName = "My New Company";
custDS.Customers.AddCustomer(newCust);

// Navigate the child relation.
foreach(CustomerDataSet.Customer customer in custDS.Customers)
{
  Console.WriteLine(customer.CustomerID);
  foreach(CustomerDataSet.Order order in customer.GetOrders())
    Console.WriteLine("\t" + order.OrderID);
}

protected static void OnCustomerChanged(object sender, CustomerDataSet.CustomerChangeEvent e)
{

}

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconusingannotationswithtypeddataset.asp

Aeros
0
 

Author Comment

by:pprasadravi
ID: 12190183
Hi Aero

Thanks for the documentation.Here is my XML file : i want to create  schema for the following xml structure and when i load xml and xsd  into dataset ,it should create one table in dataset.
If anybody have clue pls help me or if anybody have sample code it really helpfu..


<main>
             
                <SummaryInformation>
                              <PickupDate>2/2/2004</PickupDate>
                    <PickUpRecord Pickupid="6481802191">
                    <Details>
                    </Details>
                    </PickUpRecord>    
                    <NoOfPackages >44</NoOfPackages>
                    <PublishedCharge>955.75</PublishedCharge>
                    <IncentiveCredit>-231.08</IncentiveCredit>
                    <BilledCharges>724.67</BilledCharges>
               </SummaryInformation>
                 <SummaryInformation>
                              <PickupDate>2/2/2004</PickupDate>
                    <PickUpRecord Pickupid="6481802191">
                    <Details>
                    </Details>
                    </PickUpRecord>    
                    <NoOfPackages >44</NoOfPackages>
                    <PublishedCharge>955.75</PublishedCharge>
                    <IncentiveCredit>-231.08</IncentiveCredit>
                    <BilledCharges>724.67</BilledCharges>
               </SummaryInformation>
</main>


Thanks
Ravi
0
 

Author Comment

by:pprasadravi
ID: 12190255
here is my schema  :

When i load this xsd and xml  i found two table in dataset.We can change xsd structure but i can't change xml structure.

or
how do i map to the dataserver control.

It is creating the following table :

SummaryInformation
child to this is
PickupRecord

i want to bind the following elements.

Pickupdate        pickuprecord    no of packages.

pickupdate and noofpackages is in SummaryInformation and pickupid is in pickuprecord table

so how do i create dataview with summaryinformation and pickuprecord .so i can sort on any column.



<?xml version="1.0" standalone="yes" ?>
<xs:schema id="main" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
      <xs:element name="main" msdata:IsDataSet="true">
            <xs:complexType>
                  <xs:choice maxOccurs="unbounded">
                        <xs:element name="SummaryInformation">
                              <xs:complexType>
                                    <xs:sequence>
                                          <xs:element name="PickUpDate" type="xs:date" minOccurs="0" />
                                          <xs:element name="NoOfPackages" type="xs:integer" minOccurs="0" />
                                          <xs:element name="PublishedCharge" type="xs:decimal" minOccurs="0" />
                                          <xs:element name="IncentiveCredit" type="xs:decimal" minOccurs="0" />
                                          <xs:element name="BilledCharges" type="xs:decimal" minOccurs="0" />
                                          <xs:element name="PickUpRecord" minOccurs="0" maxOccurs="unbounded">
                                                <xs:complexType>
                                                      <xs:sequence>
                                                            <xs:element name="Details" type="xs:string" minOccurs="0" msdata:Ordinal="0" />
                                                      </xs:sequence>
                                                      <xs:attribute name="Pickupid" type="xs:integer" />
                                                </xs:complexType>
                                          </xs:element>
                                    </xs:sequence>
                              </xs:complexType>
                        </xs:element>
                  </xs:choice>
            </xs:complexType>
      </xs:element>
</xs:schema>


Thanks
Ravi
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12190422
bind it to a datagrid:
' Visual Basic
Dim filePath As String
filePath = "Complete path where you saved the XML file"
dsAuthors.ReadXml(filePath)
With DataGrid1
   .DataSource = dsAuthors
   .DataMember = "authors"
   .CaptionText = .DataMember
End With

Private Sub WriteXmlToFile(thisDataSet As DataSet)
    If thisDataSet Is Nothing Then
        Return
    End If
    ' Create a file name to write to.
    Dim filename As String = "myXmlDoc.xml"
    ' Create the FileStream to write with.
    Dim myFileStream As New System.IO.FileStream _
       (filename, System.IO.FileMode.Create)
    ' Create an XmlTextWriter with the fileStream.
    Dim myXmlWriter As New System.Xml.XmlTextWriter _
       (myFileStream, System.Text.Encoding.Unicode)
    ' Write to the file with the WriteXml method.
    thisDataSet.WriteXml(myXmlWriter)
    myXmlWriter.Close()
End Sub
0
 

Author Comment

by:pprasadravi
ID: 12190461
here my problem is i am able create the dataset.But i am nor sure it it creates multiple table in dataset, how can i mar to repeater.

When i want to sort on pickuprecord how can i do?
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12190471
well the datagrid handles all that for you, if you chose the repeater you would have to manually write sorting and paging routines
0
 

Author Comment

by:pprasadravi
ID: 12190801
sorry the question is not clear.I am explaining again

When i load xml and xsd into dataset.It is creating two tables.I want to create only one table in dataset.I can't change xml structure but i can chage xsd schema.

I think this time i explained better aero.

0
 
LVL 17

Accepted Solution

by:
AerosSaga earned 500 total points
ID: 12190847
Ok, I think you'll need to create a view of the schema and join the two tables before you bind then:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsqlmag02/html/definingxmlviews.asp
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12190928
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12394574
His schema forced multiple tables, his only opton was a view or to change the schema, request points.

Aeros
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now