472,811 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 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 1768
"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: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.