473,666 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parse sub elements with namespace

How can I parse the component elements per partList in the following xml
file? If I remove the namespace section of the xml my code works. I am not
sure why the namespace section impacts my code? Of course when I remove the
namespace I section I change the selectnode reference accordingly.

<?xml version="1.0"?>
<workOrderRelea sed
xmlns="http://www.qad.com/qdoc"
xmlns:enc="http ://www.w3.org/2002/12/soap-encoding"
xmlns:qcom="htt p://www.qad.com/qdoc/common"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="workOrderR eleasedWithComm ents-JITS17_1.xsd">
<workOrderRelea sed>
<corhOrderNumbe r>O1564</corhOrderNumber >
<corhSequenceNu mber>1564</corhSequenceNum ber>
<prdfId>Seat Set</prdfId>
<workOrder>
<wordId>2004112 6-00004403-00000000</wordId>
<wordDescriptio n>System Generated</wordDescription >
<wordBatchQty>1 </wordBatchQty>
<wordPreSchedul eKey>2004060114 2450-00001567</wordPreSchedule Key>
<wordBatchIdSch ed>1999</wordBatchIdSche d>
<wordBatchSeria lSched>1</wordBatchSerial Sched>
<wordReleaseOrd er>52</wordReleaseOrde r>
<wordPackOrder> 0</wordPackOrder>
<wordProcessSta tus>R</wordProcessStat us>
<wordProduction Status>R</wordProductionS tatus>
<wordBackflushS tatus>U</wordBackflushSt atus>
<wordPackStatus >U</wordPackStatus>
<wordHold>false </wordHold>
<wordCreatedDat e>2004-11-26</wordCreatedDate >
<wordCreatedTim e>10:25:05</wordCreatedTime >
<wordUpdatedDat e>2004-11-26</wordUpdatedDate >
<wordUpdatedTim e>11:50:57</wordUpdatedTime >
<wordReleaseDat e>2004-11-26</wordReleaseDate >
<wordReleaseTim e>11:08:58</wordReleaseTime >
</workOrder>
<partList>
<partId>1004872 </partId>
<paldQty>1</paldQty>
<paldSkipBackfl ush>false</paldSkipBackflu sh>
<attributeLis t>
<attributeType> BROADCASTSTRING-0</attributeType>
<attnId>LeftSea t</attnId>
<attvId>Yes</attvId>
</attributeList>
<componentLis t>
<partId>1004872 </partId>
<bomsQtyPer>1 </bomsQtyPer>
</componentList>
<componentLis t>
<partId>10048 72-A</partId>
<bomsQtyPer>1 </bomsQtyPer>
</componentList>
<componentLis t>
<partId>10048 72-B</partId>
<bomsQtyPer>1 </bomsQtyPer>
</componentList>
<componentLis t>
<partId>10048 72-C</partId>
<bomsQtyPer>1 </bomsQtyPer>
</componentList>

</partList>
<partList>
<partId>1004883 </partId>
<paldQty>1</paldQty>
<paldSkipBackfl ush>false</paldSkipBackflu sh>
<attributeLis t>
<attributeType> BROADCASTSTRING-1</attributeType>
<attnId>RightSe at</attnId>
<attvId>Yes</attvId>
</attributeList>
<componentLis t>
<partId>1004883 </partId>
<bomsQtyPer>1 </bomsQtyPer>
</componentList>
<componentLis t>
<partId>10048 83-A</partId>
<bomsQtyPer>1 </bomsQtyPer>
</componentList>
<componentLis t>
<partId>10048 83-B</partId>
<bomsQtyPer>1 </bomsQtyPer>
</componentList>
<componentLis t>
<partId>10048 83-C</partId>
<bomsQtyPer>1 </bomsQtyPer>
</componentList>
<componentLis t>
<partId>10048 83-D</partId>
<bomsQtyPer>1 </bomsQtyPer>
</componentList>
</partList>
</workOrderReleas ed>
</workOrderReleas ed>

Dim nsmgr As XmlNamespaceMan ager

nsmgr = New XmlNamespaceMan ager(objXMLDoc. NameTable)

nsmgr.AddNamesp ace("qd", "http://www.qad.com/qdoc")
'nsmgr.AddNames pace("enc", "http://www.w3.org/2002/12/soap-encoding")
'nsmgr.AddNames pace("qcom", "http://www.qad.com/qdoc/common")
'nsmgr.AddNames pace("xsi",
"http://www.w3.org/2001/XMLSchema-instance")

Dim eResults As XmlNode
eResults = objXMLDoc.Docum entElement

Dim nodes As XmlNodeList

'nodes =
eResults.Select Nodes("/workOrderReleas ed/workOrderReleas ed/partList")
nodes =
eResults.Select Nodes("/qd:workOrderRel eased/qd:workOrderRel eased/qd:partList", nsmgr)

Dim sspartId As String = objXMLDoc.NameT able.Get("partI d")
Dim spaldQty As String = objXMLDoc.NameT able.Get("paldQ ty")
Dim spaldSkipBackfl ush As String =
objXMLDoc.NameT able.Get("paldS kipBackflush")

Dim nattributeType As String =
objXMLDoc.NameT able.Get("attri buteType")
Dim nattnId As String = objXMLDoc.NameT able.Get("attnI d")
Dim nattvId As String = objXMLDoc.NameT able.Get("attvI d")
Dim spartId As String = objXMLDoc.NameT able.Get("partI d")
Dim sbomsQtyPer As String = objXMLDoc.NameT able.Get("bomsQ tyPer")

oNodes = objXMLDoc.GetEl ementsByTagName ("componentList ")
Dim oNodeCount = oNodes.Count
oNodes = objXMLDoc.GetEl ementsByTagName ("partList")
Dim pcount = oNodes.Count
ReDim partListArray(p count, 3)
ReDim componentListAr ray(pcount, oNodeCount, 2)

Dim arrayPos_0 = 0
Dim arrayPos_1 = 0

If (Not nodes Is Nothing) Then
Console.WriteLi ne("Number of interactions = " & CStr(nodes.Coun t))
For Each eInteraction As XmlNode In nodes
Dim ePchild As XmlNode = eInteraction.Fi rstChild

Dim ppartId As String
Dim paldQty As String
Dim paldSkipBackflu sh As String

While (Not ePchild Is Nothing)
If (ePchild.NodeTy pe = XmlNodeType.Ele ment) Then
If ePchild.LocalNa me = sspartId Then
ppartId = ePchild.FirstCh ild.Value
partListArray(a rrayPos_0, 0) = ppartId
ElseIf ePchild.LocalNa me = spaldQty Then
paldQty = ePchild.FirstCh ild.Value
partListArray(a rrayPos_0, 1) = paldQty
ElseIf ePchild.LocalNa me = spaldSkipBackfl ush Then
paldSkipBackflu sh = ePchild.FirstCh ild.Value
partListArray(a rrayPos_0, 2) = paldSkipBackflu sh
End If
End If
ePchild = ePchild.NextSib ling
End While
Console.WriteLi ne(partListArra y(arrayPos_0, 0) & " : " &
partListArray(a rrayPos_0, 1) & " : " & partListArray(a rrayPos_0, 2))

Dim nodesInner As XmlNodeList
'nodesInner =
eInteraction.Se lectNodes("/qd:workOrderRel eased/qd:workOrderRel eased/qd:partList/qd:componentLis t", nsmgr)
nodesInner =
eInteraction.Fi rstChild("/qd:componentLis t").SelectNodes ("/qd:components",
nsmgr)

Dim x = nodesInner.Coun t

If (Not nodesInner Is Nothing) Then
For Each ePoint As XmlNode In nodesInner

Dim eChild As XmlNode = ePoint.FirstChi ld

Dim attributeType As String
Dim attnId As String
Dim attvId As String

Dim partId As String
Dim bomsQtyPer As String

While (Not eChild Is Nothing)
If (eChild.NodeTyp e = XmlNodeType.Ele ment) Then
If eChild.LocalNam e = nattributeType Then
attributeType = eChild.FirstChi ld.Value
ElseIf eChild.LocalNam e = nattnId Then
attnId = eChild.FirstChi ld.Value
ElseIf eChild.LocalNam e = nattvId Then
attvId = eChild.FirstChi ld.Value
ElseIf eChild.LocalNam e = spartId Then
partId = eChild.FirstChi ld.Value
componentListAr ray(arrayPos_0,
arrayPos_1, 0) = partId
ElseIf eChild.LocalNam e = sbomsQtyPer Then
bomsQtyPer = eChild.FirstChi ld.Value
componentListAr ray(arrayPos_0,
arrayPos_1, 1) = bomsQtyPer
End If
End If
eChild = eChild.NextSibl ing
End While
Console.WriteLi ne("component = " & arrayPos_0 & " :
" & arrayPos_1 & " : " & partId & " : " & bomsQtyPer)
arrayPos_1 = arrayPos_1 + 1
Next
arrayPos_0 = arrayPos_0 + 1
arrayPos_1 = 0
End If
Next
End If
Thank you
Jack
Nov 12 '05 #1
1 2522


Jack Colletta wrote:
How can I parse the component elements per partList in the following xml
file? If I remove the namespace section of the xml my code works. I am not
sure why the namespace section impacts my code? <?xml version="1.0"?>
<workOrderRelea sed
xmlns="http://www.qad.com/qdoc"
xmlns:enc="http ://www.w3.org/2002/12/soap-encoding"
xmlns:qcom="htt p://www.qad.com/qdoc/common"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="workOrderR eleasedWithComm ents-JITS17_1.xsd"> <partList>
<partId>1004872 </partId>
<paldQty>1</paldQty>
<paldSkipBackfl ush>false</paldSkipBackflu sh>
<attributeLis t>
<attributeType> BROADCASTSTRING-0</attributeType>
<attnId>LeftSea t</attnId>
<attvId>Yes</attvId>
</attributeList>
<componentLis t> oNodes = objXMLDoc.GetEl ementsByTagName ("componentList ")


I haven't looked in detail at all those lines but if you have elements
in a namespace then you shouldn't use
GetElementsByTa gName("componen tList") but rather the overload that takes
an additional namespace parameter:
GetElementsByTa gName("componen tList", "http://www.qad.com/qdoc")
--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 12 '05 #2

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

Similar topics

0
4223
by: C. M. Sperberg-McQueen | last post by:
wooks (wookiz@hotmail.com) wrote: > <?xml version='1.0'?> > <userlogin xmlns="urn:faster:userlogin" > xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> > <login>mick</login> > <password>brown</password> > </userlogin> > Above is my schema instance.
8
1966
by: Hugh Sparks | last post by:
When processing an xml document that contains elements such as: <element xmlns="goop"/> ... <element xmlns="gleep"/> I want to create two xsl stylesheet templates: one that matches the elements that contain the namespace declaration for "goop" and one that matches the elements that contain the namespace declaration for "gleep".
2
6291
by: Watsh | last post by:
Hi All, I have been trying to parse an XML string using the StringReader and InputSource interface but the document returned to me is always null. Please find the code below which i have been experimenting with: import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import org.xml.sax.InputSource; import org.w3c.dom.Document;
4
6008
by: learning_C++ | last post by:
Hi, I try to use input = new istrstream(argv,strlen(argv)); in my code, but it always says error: " error: parse error before `(' token" please help me! Thanks, #include <map>
0
1098
by: Steve Jorgensen | last post by:
I'm wondering if there's an approach to writing consistent code to read/write XML data in arbitrary order that I'm simply missing. It seems to be easy getting stuff -out- of a DOM via XPath, but it's much tougher building a DOM document in arbitrary order. Yes - I can get the parent context element first, using XPath, but then I build custom wrappers and helpers to simplify the building and adding fragments in the correct namespace,...
21
2649
by: William Stacey [MVP] | last post by:
Anyone know of some library that will parse files like following: options { directory "/etc"; allow-query { any; }; // This is the default recursion no; listen-on { 192.168.0.225; }; forwarders { 4.2.2.2; }; };
5
4908
by: CindyRob | last post by:
Using .NET framework 1.1 SP1, .NET framework SDK 1.1 SP1, Visual Studio .NET 2003, hotfixes 892202 and 823639. I create a proxy class using wsdl.exe, and in the serialized XML request, I see that any elements that are nested elements in the schema (not global elements) have their namespaces set to the null namespace. I can see that the proxy classes have serialization attributes specifying these nested elements as unqualified: ///...
5
5134
by: js | last post by:
I have a textbox contains text in the format of "yyyy/MM/dd hh:mm:ss". I need to parse the text using System.DateTime.Parse() function with custom format. I got an error using the following code. Could someone help me with the customization? Thanks. String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at System.DateTime.Parse(String s, IFormatProvider...
5
64622
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called this article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts, disregarding the syntax that stream contains. Parsing is actually including the syntax in order to make...
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7385
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6192
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.