HighTechTalks DotNet Forums  

Extracting hyperlink data from XML file

Dotnet XML microsoft.public.dotnet.xml


Discuss Extracting hyperlink data from XML file in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
=?Utf-8?B?Sm9uYXRoYW4gQXR0cmVl?=
 
Posts: n/a

Default Extracting hyperlink data from XML file - 07-30-2007 , 06:52 AM






Hi
I need to extract the data from the following XML file (fragment) which
consists of and order number (in this case 415045) and some related part
numbers into a .NET dataset. The part number data is contained in other parts
of the file which are referenced by links to named anchors eg I need to
extract the 'id190' from this line of code: <ns1829687187:Part
href="#id190"/>.

How do I do this please?
Am new to XML so any help much appreciated.
Jonathan Attree

<multiRef id="id141" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns1829687187:FormatBOrder">
<ns1829687187rderNum xsi:type="xsd:string">415045</ns1829687187rderNum>
<ns1829687187:buildDate
xsi:type="xsd:dateTime">2007-07-10T23:00:00.000Z</ns1829687187:buildDate>
<ns1829687187:buildSeq xsi:type="xsd:long">515</ns1829687187:buildSeq>
<ns1829687187:vehicleLine xsi:type="xsd:string">TLS</ns1829687187:vehicleLine>
<ns1829687187fflineDate xsi:type="xsd:dateTime" xsi:nil="true"/>
<ns1829687187:Part href="#id190"/>
<ns1829687187:Part href="#id191"/>
<ns1829687187:Part href="#id192"/>
<ns1829687187:Part href="#id193"/>
<ns1829687187:Part href="#id194"/>
<ns1829687187:Part href="#id195"/>
<ns1829687187:Part href="#id196"/>
<ns1829687187:Part href="#id197"/>
<ns1829687187:Part href="#id198"/>
<ns1829687187:Part href="#id199"/>
<ns1829687187:Part href="#id200"/>
<ns1829687187:Part href="#id201"/>
<ns1829687187:Part href="#id202"/>
<ns1829687187:Part href="#id203"/>
<ns1829687187:Part href="#id204"/>
<ns1829687187:Part href="#id205"/>
</multiRef>

Reply With Quote
  #2  
Old   
Martin Honnen
 
Posts: n/a

Default Re: Extracting hyperlink data from XML file - 07-30-2007 , 07:45 AM






Jonathan Attree wrote:

Quote:
I need to extract the data from the following XML file (fragment) which
consists of and order number (in this case 415045) and some related part
numbers into a .NET dataset. The part number data is contained in other parts
of the file which are referenced by links to named anchors eg I need to
extract the 'id190' from this line of code: <ns1829687187:Part
href="#id190"/>.

Quote:
multiRef id="id141" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns1829687187:FormatBOrder"
ns1829687187rderNum xsi:type="xsd:string">415045</ns1829687187rderNum
ns1829687187:buildDate
xsi:type="xsd:dateTime">2007-07-10T23:00:00.000Z</ns1829687187:buildDate
ns1829687187:buildSeq xsi:type="xsd:long">515</ns1829687187:buildSeq
That fragment is not well-formed XML with namespaces as several prefixes
(soapenc, soapenv, xsi, ns1829687187) are not bound to a namespace URI.
So we need to see the namespace declarations if you need help processing
that XML.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #3  
Old   
Martin Honnen
 
Posts: n/a

Default Re: Extracting hyperlink data from XML file - 07-30-2007 , 07:45 AM



Jonathan Attree wrote:

Quote:
I need to extract the data from the following XML file (fragment) which
consists of and order number (in this case 415045) and some related part
numbers into a .NET dataset. The part number data is contained in other parts
of the file which are referenced by links to named anchors eg I need to
extract the 'id190' from this line of code: <ns1829687187:Part
href="#id190"/>.

Quote:
multiRef id="id141" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns1829687187:FormatBOrder"
ns1829687187rderNum xsi:type="xsd:string">415045</ns1829687187rderNum
ns1829687187:buildDate
xsi:type="xsd:dateTime">2007-07-10T23:00:00.000Z</ns1829687187:buildDate
ns1829687187:buildSeq xsi:type="xsd:long">515</ns1829687187:buildSeq
That fragment is not well-formed XML with namespaces as several prefixes
(soapenc, soapenv, xsi, ns1829687187) are not bound to a namespace URI.
So we need to see the namespace declarations if you need help processing
that XML.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #4  
Old   
=?Utf-8?B?Sm9uYXRoYW4gQXR0cmVl?=
 
Posts: n/a

Default Re: Extracting hyperlink data from XML file - 07-30-2007 , 09:46 AM




"Martin Honnen" wrote:

Quote:
That fragment is not well-formed XML with namespaces as several prefixes
(soapenc, soapenv, xsi, ns1829687187) are not bound to a namespace URI.
So we need to see the namespace declarations if you need help processing
that XML.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Thanks for the reply.
Here is a truncated version of the whole file:

<soapenv:Envelope>
<soapenv:Body
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

<getOrdersForDateRangeResponse>
<FilteredOrders href="#id0"/>
</getOrdersForDateRangeResponse>

<multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns1829687187:FormatBFilter">
<ns1829687187:filterId xsi:type="xsd:int">94</ns1829687187:filterId>
<ns1829687187:Orders href="#id4"/>
<ns1829687187:Orders href="#id5"/>
</multiRef>

<multiRef id="id5" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns1829687187:FormatBOrder">
<ns1829687187rderNum xsi:type="xsd:string">097294</ns1829687187rderNum>
<ns1829687187:buildDate
xsi:type="xsd:dateTime">2007-07-10T23:00:00.000Z</ns1829687187:buildDate>
<ns1829687187:buildSeq xsi:type="xsd:long">179</ns1829687187:buildSeq>
<ns1829687187:vehicleLine
xsi:type="xsd:string">TLS</ns1829687187:vehicleLine>
<ns1829687187fflineDate xsi:type="xsd:dateTime" xsi:nil="true"/>
<ns1829687187:Part href="#id910"/>
<ns1829687187:Part href="#id911"/>
<ns1829687187:Part href="#id912"/>
</multiRef>

<multiRef id="id910" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns1829687187:FormatBPart">
<ns1829687187refix xsi:type="xsd:string">XH42</ns1829687187refix>
<ns1829687187:base xsi:type="xsd:string">017B22</ns1829687187:base>
<ns1829687187:suffix xsi:type="xsd:string">AA</ns1829687187:suffix>
<ns1829687187artDesc xsi:type="xsd:string">SHLD VEH IDENT
LBL</ns1829687187artDesc>
<ns1829687187:freeTextField xsi:type="xsd:string">VIN STAMP CLEAR
COVER</ns1829687187:freeTextField>
<ns1829687187:qty xsi:type="xsd:double">1.0</ns1829687187:qty>
<ns1829687187:supplier xsi:type="xsd:string">L7MTA</ns1829687187:supplier>
<ns1829687187:lineFeedLoc1 xsi:type="xsd:string" xsi:nil="true"/>
<ns1829687187:lineFeedLoc2 xsi:type="xsd:string" xsi:nil="true"/>
<ns1829687187:lineFeedLoc3 xsi:type="xsd:string" xsi:nil="true"/>
<ns1829687187:lineFeedLoc4 xsi:type="xsd:string" xsi:nil="true"/>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>

The top element with type 'ns1829687187:FormatBFilter' is a list of orders
which are assigned arbitrary id nos as links (#id4, #id5). These links refer
down to next element (type 'ns1829687187:FormatBOrder') which contains the
order number. This element also contains a list of parts related to the order
no. that are also assigned id nos. (#id910, #id911, #id912). These links in
turn refer to the final element containing the part nos (prefix, base and
suffix) which is the data I need to extract from the file along with the
order no.

Hope this helps.

Jonathan Attree


Reply With Quote
  #5  
Old   
=?Utf-8?B?Sm9uYXRoYW4gQXR0cmVl?=
 
Posts: n/a

Default Re: Extracting hyperlink data from XML file - 07-30-2007 , 09:46 AM




"Martin Honnen" wrote:

Quote:
That fragment is not well-formed XML with namespaces as several prefixes
(soapenc, soapenv, xsi, ns1829687187) are not bound to a namespace URI.
So we need to see the namespace declarations if you need help processing
that XML.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Thanks for the reply.
Here is a truncated version of the whole file:

<soapenv:Envelope>
<soapenv:Body
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

<getOrdersForDateRangeResponse>
<FilteredOrders href="#id0"/>
</getOrdersForDateRangeResponse>

<multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns1829687187:FormatBFilter">
<ns1829687187:filterId xsi:type="xsd:int">94</ns1829687187:filterId>
<ns1829687187:Orders href="#id4"/>
<ns1829687187:Orders href="#id5"/>
</multiRef>

<multiRef id="id5" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns1829687187:FormatBOrder">
<ns1829687187rderNum xsi:type="xsd:string">097294</ns1829687187rderNum>
<ns1829687187:buildDate
xsi:type="xsd:dateTime">2007-07-10T23:00:00.000Z</ns1829687187:buildDate>
<ns1829687187:buildSeq xsi:type="xsd:long">179</ns1829687187:buildSeq>
<ns1829687187:vehicleLine
xsi:type="xsd:string">TLS</ns1829687187:vehicleLine>
<ns1829687187fflineDate xsi:type="xsd:dateTime" xsi:nil="true"/>
<ns1829687187:Part href="#id910"/>
<ns1829687187:Part href="#id911"/>
<ns1829687187:Part href="#id912"/>
</multiRef>

<multiRef id="id910" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns1829687187:FormatBPart">
<ns1829687187refix xsi:type="xsd:string">XH42</ns1829687187refix>
<ns1829687187:base xsi:type="xsd:string">017B22</ns1829687187:base>
<ns1829687187:suffix xsi:type="xsd:string">AA</ns1829687187:suffix>
<ns1829687187artDesc xsi:type="xsd:string">SHLD VEH IDENT
LBL</ns1829687187artDesc>
<ns1829687187:freeTextField xsi:type="xsd:string">VIN STAMP CLEAR
COVER</ns1829687187:freeTextField>
<ns1829687187:qty xsi:type="xsd:double">1.0</ns1829687187:qty>
<ns1829687187:supplier xsi:type="xsd:string">L7MTA</ns1829687187:supplier>
<ns1829687187:lineFeedLoc1 xsi:type="xsd:string" xsi:nil="true"/>
<ns1829687187:lineFeedLoc2 xsi:type="xsd:string" xsi:nil="true"/>
<ns1829687187:lineFeedLoc3 xsi:type="xsd:string" xsi:nil="true"/>
<ns1829687187:lineFeedLoc4 xsi:type="xsd:string" xsi:nil="true"/>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>

The top element with type 'ns1829687187:FormatBFilter' is a list of orders
which are assigned arbitrary id nos as links (#id4, #id5). These links refer
down to next element (type 'ns1829687187:FormatBOrder') which contains the
order number. This element also contains a list of parts related to the order
no. that are also assigned id nos. (#id910, #id911, #id912). These links in
turn refer to the final element containing the part nos (prefix, base and
suffix) which is the data I need to extract from the file along with the
order no.

Hope this helps.

Jonathan Attree


Reply With Quote
  #6  
Old   
Martin Honnen
 
Posts: n/a

Default Re: Extracting hyperlink data from XML file - 07-30-2007 , 09:54 AM



Jonathan Attree wrote:
Quote:
"Martin Honnen" wrote:

That fragment is not well-formed XML with namespaces as several prefixes
(soapenc, soapenv, xsi, ns1829687187) are not bound to a namespace URI.
So we need to see the namespace declarations if you need help processing
that XML.

Here is a truncated version of the whole file:

soapenv:Envelope
That is not well-formed either, it needs namespace declarations e.g
<soapenv:Envelope xmlns:soapenv="someURI">


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #7  
Old   
Martin Honnen
 
Posts: n/a

Default Re: Extracting hyperlink data from XML file - 07-30-2007 , 09:54 AM



Jonathan Attree wrote:
Quote:
"Martin Honnen" wrote:

That fragment is not well-formed XML with namespaces as several prefixes
(soapenc, soapenv, xsi, ns1829687187) are not bound to a namespace URI.
So we need to see the namespace declarations if you need help processing
that XML.

Here is a truncated version of the whole file:

soapenv:Envelope
That is not well-formed either, it needs namespace declarations e.g
<soapenv:Envelope xmlns:soapenv="someURI">


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #8  
Old   
=?Utf-8?B?Sm9uYXRoYW4gQXR0cmVl?=
 
Posts: n/a

Default Re: Extracting hyperlink data from XML file - 07-30-2007 , 10:20 AM





"Martin Honnen" wrote:

Quote:
Jonathan Attree wrote:
"Martin Honnen" wrote:

That fragment is not well-formed XML with namespaces as several prefixes
(soapenc, soapenv, xsi, ns1829687187) are not bound to a namespace URI.
So we need to see the namespace declarations if you need help processing
that XML.

Here is a truncated version of the whole file:

soapenv:Envelope

That is not well-formed either, it needs namespace declarations e.g
soapenv:Envelope xmlns:soapenv="someURI"


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

These are the declarations at the top of the file:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<getOrdersForDateRangeResponse
xmlns="http://obom/service/FormatB"><FilteredOrders href="#id0"
xmlns=""/></getOrdersForDateRangeResponse>

<multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns1829687187:FormatBFilter"
xmlns:ns1829687187="http://obom/service/types" xmlns="">
<ns1829687187:filterId xsi:type="xsd:int">94</ns1829687187:filterId>
<ns1829687187:Orders
..
..
..

This file is generated by my customer so I have no control over its structure.

Thanks
Jonathan Attree


Reply With Quote
  #9  
Old   
=?Utf-8?B?Sm9uYXRoYW4gQXR0cmVl?=
 
Posts: n/a

Default Re: Extracting hyperlink data from XML file - 07-30-2007 , 10:20 AM





"Martin Honnen" wrote:

Quote:
Jonathan Attree wrote:
"Martin Honnen" wrote:

That fragment is not well-formed XML with namespaces as several prefixes
(soapenc, soapenv, xsi, ns1829687187) are not bound to a namespace URI.
So we need to see the namespace declarations if you need help processing
that XML.

Here is a truncated version of the whole file:

soapenv:Envelope

That is not well-formed either, it needs namespace declarations e.g
soapenv:Envelope xmlns:soapenv="someURI"


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

These are the declarations at the top of the file:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<getOrdersForDateRangeResponse
xmlns="http://obom/service/FormatB"><FilteredOrders href="#id0"
xmlns=""/></getOrdersForDateRangeResponse>

<multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns1829687187:FormatBFilter"
xmlns:ns1829687187="http://obom/service/types" xmlns="">
<ns1829687187:filterId xsi:type="xsd:int">94</ns1829687187:filterId>
<ns1829687187:Orders
..
..
..

This file is generated by my customer so I have no control over its structure.

Thanks
Jonathan Attree


Reply With Quote
  #10  
Old   
Martin Honnen
 
Posts: n/a

Default Re: Extracting hyperlink data from XML file - 07-30-2007 , 10:31 AM



Jonathan Attree wrote:

Quote:
These are the declarations at the top of the file:

?xml version="1.0" encoding="UTF-8"?
soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
getOrdersForDateRangeResponse
xmlns="http://obom/service/FormatB"><FilteredOrders href="#id0"
xmlns=""/></getOrdersForDateRangeResponse

multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns1829687187:FormatBFilter"
xmlns:ns1829687187="http://obom/service/types" xmlns=""
ns1829687187:filterId xsi:type="xsd:int">94</ns1829687187:filterId
ns1829687187:Orders
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("file.xml");
XmlNamespaceManager namespaceManager = new
XmlNamespaceManager(xmlDoc.NameTable);
namespaceManager.AddNamespace("ns1829687187", "http://obom/service/types");
foreach (XmlElement part in xmlDoc.SelectNodes("//ns1829687187:Part",
namespaceManager)) {
Console.WriteLine("href is \"{0}\".", part.GetAttribute("href"));
}

If you only want to access the first Part element then use
SelectSingleNode instead of SelectNodes.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.