Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get complex XML data into vb.net DataSet

Status
Not open for further replies.

planetbluau

Programmer
May 25, 2010
54
AU
Hi,

I'm new to this forum and to XML. I realise this covers two forums, both vb.NET and XML, but wondering if anyone can help with a problem I am having with getting an XML into a dataset.

On trying to use DataSet1.ReadXml(myxml) I end up with an error like:

* "Nested table 'entityIdentification' which inherits its namespace cannot have multiple parent tables in different namespaces."

How can I get this XML into the dataset - can anyone point me in the right direction please. My XML file (in part) is show below.

Thanks for any help you can give.

<?xml version="1.0" encoding="UTF-8"?>
<sh:StandardBusinessDocument xmlns:sh=" xmlns:eanucc="urn:ean.ucc:2" xmlns:eek:rder="urn:ean.ucc:eek:rder:2" xmlns:xsi=" xsi:schemaLocation=" ../Schemas/sbdh/StandardBusinessDocumentHeader.xsd urn:ean.ucc:2 ../Schemas/MultiShipmentOrderProxy.xsd">
<sh:StandardBusinessDocumentHeader>
<sh:HeaderVersion>1.0</sh:HeaderVersion>
<sh:Sender>
<sh:Identifier Authority="EAN.UCC">9377776020419</sh:Identifier>
</sh:Sender>
<sh:Receiver>
<sh:Identifier Authority="EAN.UCC">9377776000001</sh:Identifier>
</sh:Receiver>
<sh:DocumentIdentification>
<sh:Standard>EAN.UCC</sh:Standard>
<sh:TypeVersion>2.4</sh:TypeVersion>
<sh:InstanceIdentifier>1234567</sh:InstanceIdentifier>
<sh:Type>MultiShipmentOrder</sh:Type>
<sh:CreationDateAndTime>2008-01-01T12:00:00.000+08:00</sh:CreationDateAndTime>
</sh:DocumentIdentification>
</sh:StandardBusinessDocumentHeader>
<eanucc:message>
<entityIdentification>
<uniqueCreatorIdentification>MSG-1234567</uniqueCreatorIdentification>
<contentOwner>
<gln>9377778020419</gln>
</contentOwner>
</entityIdentification>
<eanucc:transaction>
<entityIdentification>
<uniqueCreatorIdentification>TRA-1234567</uniqueCreatorIdentification>
<contentOwner>
<gln>9377778020419</gln>
</contentOwner>
</entityIdentification>
<command>
<eanucc:documentCommand>
<documentCommandHeader type="ADD">
<entityIdentification>
<uniqueCreatorIdentification>CMD-1234563</uniqueCreatorIdentification>
<contentOwner>
<gln>9377778020419</gln>
</contentOwner>
</entityIdentification>
</documentCommandHeader>
<documentCommandOperand>
<order:multiShipmentOrder creationDateTime="2008-01-01T00:00:00.000+08:00" documentStatus="ORIGINAL">
<contentVersion>
<versionIdentification>2.4</versionIdentification>
</contentVersion>
<documentStructureVersion>
<versionIdentification>2.4</versionIdentification>
</documentStructureVersion>
<orderIdentification>
<uniqueCreatorIdentification>2010X02456789</uniqueCreatorIdentification>
<contentOwner>
<gln>9377778020412</gln>
</contentOwner>
</orderIdentification>
<orderPartyInformation>
<seller>
<gln>9377778000002</gln>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>HHS001</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>BUYER_ASSIGNED_IDENTIFIER_FOR_A_PARTY</additionalPartyIdentificationType>
</additionalPartyIdentification>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>HARRY'S HARDWARE SUPPLIES</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>FOR_INTERNAL_USE_1</additionalPartyIdentificationType>
</additionalPartyIdentification>
</seller>
<billTo>
<gln>9325724002019</gln>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>2010</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>BUYER_ASSIGNED_IDENTIFIER_FOR_A_PARTY</additionalPartyIdentificationType>
</additionalPartyIdentification>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>FREDS BALCATTA W/H</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>FOR_INTERNAL_USE_1</additionalPartyIdentificationType>
</additionalPartyIdentification>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>11 BALCATTA ROAD BALCATTA WA 6021</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>FOR_INTERNAL_USE_2</additionalPartyIdentificationType>
</additionalPartyIdentification>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>08 9344 4311</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>FOR_INTERNAL_USE_3</additionalPartyIdentificationType>
</additionalPartyIdentification>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>08 9345 4311</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>FOR_INTERNAL_USE_4</additionalPartyIdentificationType>
</additionalPartyIdentification>
</billTo>
<buyer>
<gln>9377778020419</gln>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>FREDS_AU</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>BUYER_ASSIGNED_IDENTIFIER_FOR_A_PARTY</additionalPartyIdentificationType>
</additionalPartyIdentification>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>FREDS LIMITED</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>FOR_INTERNAL_USE_1</additionalPartyIdentificationType>
</additionalPartyIdentification>
</buyer>
<orderContact>
<personOrDepartmentName>
<description>
<language>
<languageISOCode>EN</languageISOCode>
</language>
<text>Balcatta Warehouse</text>
</description>
</personOrDepartmentName>
</orderContact>
</orderPartyInformation>
<orderLogisticalInformation>
<shipToLogistics>
<shipTo>
<gln>9325724002019</gln>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>2010</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>BUYER_ASSIGNED_IDENTIFIER_FOR_A_PARTY</additionalPartyIdentificationType>
</additionalPartyIdentification>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>FREDS BALCATTA W/H</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>FOR_INTERNAL_USE_1</additionalPartyIdentificationType>
</additionalPartyIdentification>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>11 BALCATTA ROAD BALCATTA WA 6021</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>FOR_INTERNAL_USE_2</additionalPartyIdentificationType>
</additionalPartyIdentification>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>08 9344 4311</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>FOR_INTERNAL_USE_3</additionalPartyIdentificationType>
</additionalPartyIdentification>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>08 9345 4311</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>FOR_INTERNAL_USE_4</additionalPartyIdentificationType>
</additionalPartyIdentification>
</shipTo>
<shipFrom>
<gln>9377778000000</gln>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>WA.WELLINGTON</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>BUYER_ASSIGNED_IDENTIFIER_FOR_A_PARTY</additionalPartyIdentificationType>
</additionalPartyIdentification>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>HARRY'S HARDWARE DC</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>FOR_INTERNAL_USE_1</additionalPartyIdentificationType>
</additionalPartyIdentification>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>29 CORNER ROAD WELLINGTON WA 6545</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>FOR_INTERNAL_USE_2</additionalPartyIdentificationType>
</additionalPartyIdentification>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>08 9999 5551</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>FOR_INTERNAL_USE_3</additionalPartyIdentificationType>
</additionalPartyIdentification>
<additionalPartyIdentification>
<additionalPartyIdentificationValue>08 9999 4414</additionalPartyIdentificationValue>
<additionalPartyIdentificationType>FOR_INTERNAL_USE_4</additionalPartyIdentificationType>
</additionalPartyIdentification>
</shipFrom>
</shipToLogistics>
<orderLogisticalDateGroup>
<requestedDeliveryDate>
<date>2008-01-04</date>
</requestedDeliveryDate>
</orderLogisticalDateGroup>
</orderLogisticalInformation>
<multiShipmentOrderLineItem number="1" >
<requestedQuantity>
<value>5.00</value>
<unitOfMeasure>
<measurementUnitCodeValue>EA</measurementUnitCodeValue>
</unitOfMeasure>
</requestedQuantity>
<netPrice>
<amount>
<currencyCode>
<currencyISOCode>AUD</currencyISOCode>
</currencyCode>
<monetaryAmount>2.50</monetaryAmount>
</amount>
</netPrice>
<netAmount>
<amount>
<currencyCode>
<currencyISOCode>AUD</currencyISOCode>
</currencyCode>
<monetaryAmount>12.50</monetaryAmount>
</amount>
</netAmount>
<tradeItemIdentification>
<gtin>09123456789123</gtin>
<additionalTradeItemIdentification>
<additionalTradeItemIdentificationValue>HAM123</additionalTradeItemIdentificationValue>
<additionalTradeItemIdentificationType>SUPPLIER_ASSIGNED</additionalTradeItemIdentificationType>
</additionalTradeItemIdentification>
<additionalTradeItemIdentification>
<additionalTradeItemIdentificationValue>HAMMER</additionalTradeItemIdentificationValue>
<additionalTradeItemIdentificationType>FOR_INTERNAL_USE_1</additionalTradeItemIdentificationType>
</additionalTradeItemIdentification>
<additionalTradeItemIdentification>
<additionalTradeItemIdentificationValue>1</additionalTradeItemIdentificationValue>
<additionalTradeItemIdentificationType>FOR_INTERNAL_USE_2</additionalTradeItemIdentificationType>
</additionalTradeItemIdentification>
</tradeItemIdentification>
</multiShipmentOrderLineItem>
<multiShipmentOrderLineItem number="2" >
<requestedQuantity>
<value>2.00</value>
<unitOfMeasure>
<measurementUnitCodeValue>EA</measurementUnitCodeValue>
</unitOfMeasure>
</requestedQuantity>
<netPrice>
<amount>
<currencyCode>
<currencyISOCode>AUD</currencyISOCode>
</currencyCode>
<monetaryAmount>12.00</monetaryAmount>
</amount>
</netPrice>
<netAmount>
<amount>
<currencyCode>
<currencyISOCode>AUD</currencyISOCode>
</currencyCode>
<monetaryAmount>24.00</monetaryAmount>
</amount>
</netAmount>
<tradeItemIdentification>
<gtin>09123456789111</gtin>
<additionalTradeItemIdentification>
<additionalTradeItemIdentificationValue>DRILL SET</additionalTradeItemIdentificationValue>
<additionalTradeItemIdentificationType>FOR_INTERNAL_USE_1</additionalTradeItemIdentificationType>
</additionalTradeItemIdentification>
<additionalTradeItemIdentification>
<additionalTradeItemIdentificationValue>1</additionalTradeItemIdentificationValue>
<additionalTradeItemIdentificationType>FOR_INTERNAL_USE_2</additionalTradeItemIdentificationType>
</additionalTradeItemIdentification>
</tradeItemIdentification>
</multiShipmentOrderLineItem>
<multiShipmentOrderLineItem number="3" >
<requestedQuantity>
<value>10.00</value>
<unitOfMeasure>
<measurementUnitCodeValue>EA</measurementUnitCodeValue>
</unitOfMeasure>
</requestedQuantity>
<netPrice>
<amount>
<currencyCode>
<currencyISOCode>AUD</currencyISOCode>
</currencyCode>
<monetaryAmount>25.00</monetaryAmount>
</amount>
</netPrice>
<netAmount>
<amount>
<currencyCode>
<currencyISOCode>AUD</currencyISOCode>
</currencyCode>
<monetaryAmount>250.00</monetaryAmount>
</amount>
</netAmount>
<tradeItemIdentification>
<gtin>09123456789132</gtin>
<additionalTradeItemIdentification>
<additionalTradeItemIdentificationValue>WHEEL BARROW</additionalTradeItemIdentificationValue>
<additionalTradeItemIdentificationType>FOR_INTERNAL_USE_1</additionalTradeItemIdentificationType>
</additionalTradeItemIdentification>
<additionalTradeItemIdentification>
<additionalTradeItemIdentificationValue>1</additionalTradeItemIdentificationValue>
<additionalTradeItemIdentificationType>FOR_INTERNAL_USE_2</additionalTradeItemIdentificationType>
</additionalTradeItemIdentification>
</tradeItemIdentification>
</multiShipmentOrderLineItem>
<additionalOrderInstruction>
<language>
<languageISOCode>EN</languageISOCode>
</language>
<longText>GDS/INW BALCATTA-COST EXCL GST QUOTE O/NO ON C/NOTE - INV WITH GOODS</longText>
</additionalOrderInstruction>
<totalMonetaryAmountOfOrder>
<currencyCode>
<currencyISOCode>AUD</currencyISOCode>
</currencyCode>
<monetaryAmount>286.50</monetaryAmount>
</totalMonetaryAmountOfOrder>
<orderHeaderIndicator>
<isApplicationReceiptAcknowledgementRequired>true</isApplicationReceiptAcknowledgementRequired>
<isOrderFreeOfExciseTaxDuty>true</isOrderFreeOfExciseTaxDuty>
</orderHeaderIndicator>
</order:multiShipmentOrder>
</documentCommandOperand>
</eanucc:documentCommand>
</command>
</eanucc:transaction>
</eanucc:message>
</sh:StandardBusinessDocument>
 
The listing of the xml is not complete or present in the manner digested. In any case, the error is related to some limitation of the use of DataSet to read xml document. Hence, a consequence is that DataSet, at present, can map only a subset of admissible xml document as source. Ms says it is by design, hence, just a feature.

The error mainly comes from the use of ado.net schema inference. In any case, the stacktrace will probably show you somewhere a line like:
[tt] at System.Data.DataSet.InferSchema(XmlDocument xdoc, String[] excludedNamespaces, XmlReadMode mode)[/tt]

These are some pertinent references.
 
The XML is either in an invalid format, or just a format that can't be used to create a DataSet with. You will either have to alter the structure or use some other method (e.g. create your own object that maps directly to the structure).

Mark,

Darlington Web Design[tab]|[tab]Experts, Information, Ideas & Knowledge[tab]|[tab]ASP.NET Tips & Tricks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top