472,784 Members | 939 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,784 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 6380
"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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 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...
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
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: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.