473,322 Members | 1,671 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,322 software developers and data experts.

xml selectnodes

i want to get childs of specific xml node. normally i use

xmlNodeList fooList = myNode.SelectNodes("foo");

but in compactframework , there is no selectNodes() method or
selectSingleNode() method.

what else can i use instead?
Nov 12 '05 #1
8 6408
"e-mid" <someone@somewhere> wrote in message news:OP**************@TK2MSFTNGP10.phx.gbl...
i want to get childs of specific xml node. normally i use

xmlNodeList fooList = myNode.SelectNodes("foo");
The luxury of the desktop! (to get child nodes, SelectNodes() is
overkill.)
but in compactframework , there is no selectNodes() method or
selectSingleNode() method.

what else can i use instead?


Try myNode.ChildNodes. It's an XmlNodeList that you can
iterate over, and check the LocalName property on each
XmlNode in ChildNodes to see if it's "foo".
Derek Harmon
Nov 12 '05 #2
thknz Derek.
"Derek Harmon" <lo*******@msn.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
"e-mid" <someone@somewhere> wrote in message

news:OP**************@TK2MSFTNGP10.phx.gbl...
i want to get childs of specific xml node. normally i use

xmlNodeList fooList = myNode.SelectNodes("foo");


The luxury of the desktop! (to get child nodes, SelectNodes() is
overkill.)
but in compactframework , there is no selectNodes() method or
selectSingleNode() method.

what else can i use instead?


Try myNode.ChildNodes. It's an XmlNodeList that you can
iterate over, and check the LocalName property on each
XmlNode in ChildNodes to see if it's "foo".
Derek Harmon

Nov 12 '05 #3
Yaar it is working
-----Original Message-----
thknz Derek.
"Derek Harmon" <lo*******@msn.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
"e-mid" <someone@somewhere> wrote in message

news:OP**************@TK2MSFTNGP10.phx.gbl...
> i want to get childs of specific xml node. normally i use >
> xmlNodeList fooList = myNode.SelectNodes("foo");


The luxury of the desktop! (to get child nodes, SelectNodes() is overkill.)
> but in compactframework , there is no selectNodes() method or > selectSingleNode() method.
>
> what else can i use instead?


Try myNode.ChildNodes. It's an XmlNodeList that you can
iterate over, and check the LocalName property on each
XmlNode in ChildNodes to see if it's "foo".
Derek Harmon

.

Nov 12 '05 #4
Actually I m testing this News Group...
bcos i want to develop samething...
-----Original Message-----
i want to get childs of specific xml node. normally i use

xmlNodeList fooList = myNode.SelectNodes("foo");

but in compactframework , there is no selectNodes() method orselectSingleNode() method.

what else can i use instead?
.

Nov 12 '05 #5
Yaar I want to Know the complete herachy of this
system...How it work...i mean how message link with each
other
-----Original Message-----
i want to get childs of specific xml node. normally i use

xmlNodeList fooList = myNode.SelectNodes("foo");

but in compactframework , there is no selectNodes() method orselectSingleNode() method.

what else can i use instead?
.

Nov 12 '05 #6
This is working...i got it...how it is working
-----Original Message-----
Actually I m testing this News Group...
bcos i want to develop samething...
-----Original Message-----
i want to get childs of specific xml node. normally i use

xmlNodeList fooList = myNode.SelectNodes("foo");

but in compactframework , there is no selectNodes()

method or
selectSingleNode() method.

what else can i use instead?
.

.

Nov 12 '05 #7
Suresh Kumar wrote:
Actually I m testing this News Group...
bcos i want to develop samething...


Please, test in microsoft.public.test.here newsgroup.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #8
Here are some replacements I wrote which provide a subset of the "real"
framework:

' This function replicates the SelectSingleNode MSXML function only
to the extent required by

' expressions such as /starting/next/next/element or
/starting/next/next/element/@attribute

Public Function SelectSingleNode(ByVal xmldoc As XmlDocument, ByVal
sInput As String) As String

Dim sSelect() As String, sXML As String, i As Integer, xNode As
XmlNode, tNode As XmlNode

' Break down the input string

sSelect = Split(sInput, "/")

If UBound(sSelect) < 1 Then Return ""

' Get the first node

xNode = xmldoc.GetElementsByTagName(sSelect(1)).Item(0)

' go to the next-to-last element

For i = 2 To UBound(sSelect) - 1

If xNode.HasChildNodes Then

For Each tNode In xNode.ChildNodes

If tNode.Name = sSelect(i) Then

xNode = tNode

Exit For

End If

Next

Else

Return ""

End If

Next

' Handle last node or attribute

If Mid(sSelect(i), 1, 1) = "@" Then

If xNode.Attributes(Mid(sSelect(i), 2)) Is Nothing Then

Return ""

Else

Return xNode.Attributes(Mid(sSelect(i), 2)).InnerText

End If

Else

For Each tNode In xNode.ChildNodes

If tNode.Name = sSelect(i) Then

xNode = tNode

Exit For

End If

Next

If xNode Is Nothing Then Return ""

Return xNode.InnerText

End If

End Function

' This function replicates the SelectNodes MSXML function only to
the extent required by

' expressions such as /starting/next/next/element or
/starting/next/next/element/*

Public Function SelectNodes(ByVal xmldoc As XmlDocument, ByVal
sInput As String) As XmlNode()

Dim sSelect() As String, sXML As String, i As Integer, xNode As
XmlNode, tNode As XmlNode

Dim xList() As XmlNode

' Break down the input string

sSelect = Split(sInput, "/")

If UBound(sSelect) < 1 Then Return Nothing

' Get the first node

xNode = xmldoc.GetElementsByTagName(sSelect(1)).Item(0)

' go to the next-to-last element

For i = 2 To UBound(sSelect) - 1

If xNode.HasChildNodes Then

For Each tNode In xNode.ChildNodes

If tNode.Name = sSelect(i) Then

xNode = tNode

Exit For

End If

Next

Else

Return Nothing

End If

Next

' Handle last node

If Not xNode.HasChildNodes Then Return Nothing

For Each tNode In xNode.ChildNodes

If tNode.Name = sSelect(i) Or sSelect(i) = "*" Then

' Re-size array

If xList Is Nothing Then

' First time through, create the array

ReDim xList(0)

xList(0) = Nothing

Else

' Increase size by 1

ReDim Preserve xList(xList.Length())

End If

xList(xList.Length - 1) = tNode

End If

Next

If xList(0) Is Nothing Then Return Nothing

Return xList

End Function

"e-mid" <someone@somewhere> wrote in message
news:OP**************@TK2MSFTNGP10.phx.gbl...
i want to get childs of specific xml node. normally i use

xmlNodeList fooList = myNode.SelectNodes("foo");

but in compactframework , there is no selectNodes() method or
selectSingleNode() method.

what else can i use instead?

Nov 12 '05 #9

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

Similar topics

7
by: Robert Mark Bram | last post by:
Hi All! In the code below, I am reading in an xhtml document and attempting to use selectNodes to find a <p id="rmb"> node.. But the result is: 2 - */* 0 - */p Can anyone suggest what I...
4
by: Andrew Parsons | last post by:
Hey all, I have the following code to get a set of nodes containing a certain search criteria: theSearchTermsXML.selectNodes("/Table/Row/Cell") This works fine to a point - it finds all...
1
by: Riko Eksteen | last post by:
Hi I am writing an application that listens to the NodeInserted event, and if the event is fired it does a selectnodes xpath query on the XmlDocument. Only problem is, when I call...
2
by: Michael H | last post by:
Hello group, I have a some xml that looks like this below: <tuneRequests ct="3" xmlns:sql="urn:schemas-microsoft-com:xml-sql" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <tr...
2
by: Linda Boumarafi | last post by:
Hi, This is a newbie question to XMLNS. I just finished the article on "XML Namespaces and How They Affect XPath and XSLT" by Dare Obasanjo and I'm pretty sure I understand the problem. I just...
2
by: Joe | last post by:
Hello All: Does anyone know the differnce between the GetElementsByTagName method and the SelectNodes method? I know that they take different arguments. They also both return a NodeList. I'm...
2
by: DeveloperX | last post by:
SelectNodes under 1.1 is confusing me. Imagine an xml file that looks like this. It's just an example: <drive> <dir a="a"> <file>aA</file> <file>aB</file> <dir a="ab"> <file>abA</file> <dir...
3
by: John Smith | last post by:
I'm trying to make some Javascript X-browser. foo is a HTML DOM. I have foo.documentElement.selectNodes("xpath"); in the source. I see later down there is also a foo.transformNode. Yuck. ...
3
by: Alan Mailer | last post by:
Ok, I've looked for an answer for this, because I'm sure it's been asked a thousand times... but no luck... so here goes. Imagine I want to create a NodeList based on an XPath statement. The...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.