473,395 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

XML File valid, but not valid with ADO.NET

I have some xml from a company that usees the same xml tag underneath
different nodes. The xml is valid, but ADO.net complains when I try to load
it into a dataset. It gives me the error:

Although this XML document is well formed, it contains structure that Data
view cannot display.
The same table (Table name) cannot be the child table in two nested
relations.

I get the same error when I try to load up the xml document into the visual
studio .net IDE and browse the data through the GUI.

Microsoft has a knowledge base article about this, but doesn't say how to
resolve it. kb article
http://support.microsoft.com/default...b;en-us;325696

Here is the sample xml file, it has two item nodes underneath different
parent nodes and I need to be able to load up this xml in a dataset for
display purposes. Does anyone have any idea how to acomplish this?

Thanks!
-----------------------------------------------------------
<?xml version="1.0" ?>
<OrdersInventoryData>
<Order>
<Item>
<id>1</id>
<qty>5</qty>
</Item>
</Order>
<Inventory>
<Item>
<id>1</id>
<qty>100</qty>
</Item>
</Inventory>
</OrdersInventoryData>
-----------------------------------------------------------

Nov 12 '05 #1
2 1784
"Michael Kuzminski" <Mi**************@discussions.microsoft.com> wrote in message
news:B1**********************************@microsof t.com...
The xml is valid, but ADO.net complains when I try to load
it into a dataset. It gives me the error:
The same table (Table name) cannot be the child table in two nested
relations.
The error is correct because the XML isn't structured in a manner
allowing ADO.NET to infer how it should be represented within
a DataSet.
Microsoft has a knowledge base article about this, but doesn't say how to
resolve it. kb article
http://support.microsoft.com/default...b;en-us;325696
One solution would take this structure to provide foreign keys relating
Order and Inventory each to an ItemDetail, like this (omitted are any
ADO.NET's metadata attributes, essentially create the non-nested
relationships manually),

- - - normal.xml
<?xml version="1.0" ?>
<OrdersInventoryData>
<Order>
<ItemDetailNo>1</ItemDetailNo>
</Order>
<Inventory>
<ItemDetailNo>2</ItemDetailNo>
</Inventory>
<ItemDetail>
<detailno>1</detailno>
<id>1</id>
<qty>5</qty>
</ItemDetail>
<ItemDetail>
<detailno>2</detailno>
<id>1</id>
<qty>100</qty>
</ItemDetail>
</OrdersInventoryData>
- - -
I need to be able to load up this xml in a dataset for
display purposes. Does anyone have any idea how to acomplish this?


All solutions involve adapting your XML into something DataSet
finds palatable, whether manually, by XSLT, by XmlReader filter,
or in some other way.

Use XmlDocument if you need to import well-formed, but not
necessarily relationally-structured XML. If necessary, implement
an IBindingList wrapper around your XmlDocument so you can
data-bind to it.

Nov 12 '05 #2
I have an idea, based on the assumption that the <Item> under <Order>
and the <Item> under <Inventory> have different structure and so
cannot, ultimately, be shoehorned into the same ADO.NET database table.
If this is not so then I recommend Derek's solution.

Use XSLT (either outside your application as a pre-processing step, or
within .NET as a call) to change the names of the nodes from <Item> to
<OrderItem> and <InventoryItem>, respectively, then pull the resulting
XML document into ADO.NET. ADO.NET should then happily create two
separate tables, one called OrderItem and one called InventoryItem.

You can do this easily from within your application using the
XslTransform class's Load() and Transform() methods. You should then be
able to pass the resulting XmlReader to a DataSet's Load() method to
load the altered XML into ADO.NET.

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Jeff Wagner | last post by:
I am importing a file which contains a persons name (firstName, middleName, etc). If I define a function to do this, how can I use the variables outside of that function? Here is the code: ...
3
by: code_wrong | last post by:
hi, I decided to extract the text from some powerpoint files. The results have thrown up some questions. When I use the 'char *valid' character array (in the program below) to choose the...
3
by: Chris | last post by:
Hi, In C# I tried to save a file from a generated file name. Just before launching the dialog I check for a valid file name to be sure. There for I used the method ValidateNames from the save...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
5
by: Joe Van Dyk | last post by:
I have a file that looks like this: 25.000000 55.000000 23.000000 51.000000 5 8 8700 6000 <and then, at byte 128, starts binary stuff> What's the proper way to make sure that I'm reading in...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
6
by: Daniel Padron | last post by:
Ok. Maybe I shouldnt post such basic questions here in such an advanced group but my high school programming teacher wont answer any questions outside of his curriculum :( My goal is create a...
3
by: Eric Lilja | last post by:
Sorry for asking so many questions, but I've just started and need to get some things working so I can do the task that is before me. Consider this (validating) schema: <?xml version="1.0"?>...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
8
by: =?Utf-8?B?Q2hyaXMgRmluaw==?= | last post by:
I am trying to make a minor modification to the code below and need some assistance. Currently this code is using the java.util, java.util.zip, and java.io assemblies from the vjslib.dll assembly....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.