XmlDataDocument problem

Hi,

I have a problem reading xml into a dataset using the XmlDataDocument.
In a test project, I created the following xml file:

<?xml version="1.0" standalone="yes"?>
<Customer>
	<OrderDetails>
		<OrderID>5</OrderID>
		<ProductID>6</ProductID>
	</OrderDetails>
</Customer>

And I use the following code to read it:

TestDataSet ds = new TestDataSet(); // TestDataSet is a typed dataset
with 1 table "OrderDetails", with 1 column "OrderID"
System.Xml.XmlDataDocument doc = new System.Xml.XmlDataDocument(ds);
doc.Load("Test.xml");

foreach (TestDataSet.OrderDetailsRow row in ds.OrderDetails)
{
	Console.WriteLine(row.OrderID);
}

ds.OrderDetails always has a rowcount of 0.

It works when I change the xml to this:

<?xml version="1.0" standalone="yes"?>
<DataSet xmlns="http://tempuri.org/TestDataSet.xsd">
<Customer>
	<OrderDetails>
		<OrderID>5</OrderID>
		<ProductID>6</ProductID>
	</OrderDetails>
</Customer>
</DataSet>

I used this article to create my test project:
http://msdn2.microsoft.com/en-us/library/k4swfa13(VS.80).aspx and I
see no "<DataSet xmlns="http://tempuri.org/TestDataSet.xsd">" line in
the example xml there

0
5/9/2007 7:29:14 AM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
1394 Views

Similar Articles

[PageSpeed] 22

> Hi,
> 
> I have a problem reading xml into a dataset using the XmlDataDocument.
> In a test project, I created the following xml file:
> 
> <?xml version="1.0" standalone="yes"?>
> <Customer>
> 	<OrderDetails>
> 		<OrderID>5</OrderID>
> 		<ProductID>6</ProductID>
> 	</OrderDetails>
> </Customer>
> 
> And I use the following code to read it:
> 
> TestDataSet ds = new TestDataSet(); // TestDataSet is a typed dataset
> with 1 table "OrderDetails", with 1 column "OrderID"
> System.Xml.XmlDataDocument doc = new System.Xml.XmlDataDocument(ds);
> doc.Load("Test.xml");
> 
> foreach (TestDataSet.OrderDetailsRow row in ds.OrderDetails)
> {
> 	Console.WriteLine(row.OrderID);
> }
> 
> ds.OrderDetails always has a rowcount of 0.
> 
> It works when I change the xml to this:
> 
> <?xml version="1.0" standalone="yes"?>
> <DataSet xmlns="http://tempuri.org/TestDataSet.xsd">
> <Customer>
> 	<OrderDetails>
> 		<OrderID>5</OrderID>
> 		<ProductID>6</ProductID>
> 	</OrderDetails>
> </Customer>
> </DataSet>
> 
> I used this article to create my test project:
> http://msdn2.microsoft.com/en-us/library/k4swfa13(VS.80).aspx and I
> see no "<DataSet xmlns="http://tempuri.org/TestDataSet.xsd">" line in
> the example xml there


Please give me advice how I write the code for use the string as the input. How to create a function that takes a string and outputs a Dataset. Please if you can give me cods because I am trying but get nothing. Providing you cods below down where I stuck.

Rgards

Maninder Singh


BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
0
5/25/2007 1:00:11 PM
> Hi,
> 
> I have a problem reading xml into a dataset using the XmlDataDocument.
> In a test project, I created the following xml file:
> 
> <?xml version="1.0" standalone="yes"?>
> <Customer>
> 	<OrderDetails>
> 		<OrderID>5</OrderID>
> 		<ProductID>6</ProductID>
> 	</OrderDetails>
> </Customer>
> 
> And I use the following code to read it:
> 
> TestDataSet ds = new TestDataSet(); // TestDataSet is a typed dataset
> with 1 table "OrderDetails", with 1 column "OrderID"
> System.Xml.XmlDataDocument doc = new System.Xml.XmlDataDocument(ds);
> doc.Load("Test.xml");
> 
> foreach (TestDataSet.OrderDetailsRow row in ds.OrderDetails)
> {
> 	Console.WriteLine(row.OrderID);
> }
> 
> ds.OrderDetails always has a rowcount of 0.
> 
> It works when I change the xml to this:
> 
> <?xml version="1.0" standalone="yes"?>
> <DataSet xmlns="http://tempuri.org/TestDataSet.xsd">
> <Customer>
> 	<OrderDetails>
> 		<OrderID>5</OrderID>
> 		<ProductID>6</ProductID>
> 	</OrderDetails>
> </Customer>
> </DataSet>
> 
> I used this article to create my test project:
> http://msdn2.microsoft.com/en-us/library/k4swfa13(VS.80).aspx and I
> see no "<DataSet xmlns="http://tempuri.org/TestDataSet.xsd">" line in
> the example xml there

Please give me advice how I write the code for use the string as the input. How to create a function that takes a string and outputs a Dataset. Please if you can give me cods because I am trying but get nothing. Providing you cods below down where I stuck.

Rgards

Maninder Singh


BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
0
5/25/2007 1:02:42 PM
> Hi,
> 
> I have a problem reading xml into a dataset using the XmlDataDocument.
> In a test project, I created the following xml file:
> 
> <?xml version="1.0" standalone="yes"?>
> <Customer>
> 	<OrderDetails>
> 		<OrderID>5</OrderID>
> 		<ProductID>6</ProductID>
> 	</OrderDetails>
> </Customer>
> 
> And I use the following code to read it:
> 
> TestDataSet ds = new TestDataSet(); // TestDataSet is a typed dataset
> with 1 table "OrderDetails", with 1 column "OrderID"
> System.Xml.XmlDataDocument doc = new System.Xml.XmlDataDocument(ds);
> doc.Load("Test.xml");
> 
> foreach (TestDataSet.OrderDetailsRow row in ds.OrderDetails)
> {
> 	Console.WriteLine(row.OrderID);
> }
> 
> ds.OrderDetails always has a rowcount of 0.
> 
> It works when I change the xml to this:
> 
> <?xml version="1.0" standalone="yes"?>
> <DataSet xmlns="http://tempuri.org/TestDataSet.xsd">
> <Customer>
> 	<OrderDetails>
> 		<OrderID>5</OrderID>
> 		<ProductID>6</ProductID>
> 	</OrderDetails>
> </Customer>
> </DataSet>
> 
> I used this article to create my test project:
> http://msdn2.microsoft.com/en-us/library/k4swfa13(VS.80).aspx and I
> see no "<DataSet xmlns="http://tempuri.org/TestDataSet.xsd">" line in
> the example xml there

Dataset ds = CreateFromString(xml); 

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
0
5/25/2007 1:12:00 PM
Reply:

Similar Artilces: