473,545 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help on looping throug a xml file to find a specific innerxml

Hello.

I need to loop through a xml file finding a specific innerxml text and then
ad the content to a treeview.

For example. If the innerxml im searching for is "item001" then I want the
content in <items></items>

added to my treeview.

<items>
<item>item001 </item>
<more_item>stuf f</more_item>
</items>

Any ideas how to do that.

I must admit I have little xml and treeview experience so I hope you are
able to help or guide me to an examble.

Thanks

//Janhm
Nov 17 '05 #1
15 3291
In message <eb************ **********@news .easynews.com>, janhm
<no******@this. adr> writes
Hello.

I need to loop through a xml file finding a specific innerxml text and then
ad the content to a treeview.


Use an XPATH query. Look up the SelectNodes method of the
XmlDataDocument class.

--
Steve Walker
Nov 17 '05 #2
thanks, will have a look..
//janhm

Use an XPATH query. Look up the SelectNodes method of the XmlDataDocument
class.

--
Steve Walker

Nov 17 '05 #3
It appears that XPATH isn't supported, as im developing for a smart device..

any other ideas ?
//Jan

Use an XPATH query. Look up the SelectNodes method of the XmlDataDocument
class.

--
Steve Walker

Nov 17 '05 #4
XmlReader r = new XmlTextReader(" myfile.xml");

while(r.Read())
{
r.MoveToContent (); // move past whitespace, comments, etc
if( r.NodeType == XmlNodeType.Ele ment && r.LocalName== <nodename> && r.NamespaceUri= =<namespace>)
{
r.Read(); // move to the text node of the required element
MessageBox.Show (r.Value); // get the text node value
}
}

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

It appears that XPATH isn't supported, as im developing for a smart device..

any other ideas ?
//Jan

Use an XPATH query. Look up the SelectNodes method of the XmlDataDocument
class.

--
Steve Walker


[microsoft.publi c.dotnet.langua ges.csharp]
Nov 17 '05 #5
In message <mq************ **********@news .easynews.com>, janhm
<no******@this. adr> writes
Use an XPATH query. Look up the SelectNodes method of the XmlDataDocument
class.
It appears that XPATH isn't supported, as im developing for a smart device..


That's a bit rubbish.

I was once involved in an eVB project, and I'm pretty sure we used MSXML
to evaluate XPATH expressions on a PDA. I wrote the synchronisation
software in C#, but I think I remember helping the eVB guy with XPATH
syntax.

You might be able to use MSXML via COM interop, but I think it's
probably simpler just to iterate the nodes and examine them.

--
Steve Walker
Nov 17 '05 #6
Of course - that would require COM interop to be supported ;-)

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

That's a bit rubbish.

I was once involved in an eVB project, and I'm pretty sure we used MSXML
to evaluate XPATH expressions on a PDA. I wrote the synchronisation
software in C#, but I think I remember helping the eVB guy with XPATH
syntax.

You might be able to use MSXML via COM interop, but I think it's
probably simpler just to iterate the nodes and examine them.

Nov 17 '05 #7
hmm, I don't know so much about this. (comming from delphi programming)..

I got an error and goggled for it.. found this one :

http://groups.google.dk/groups?hl=da...gbl%26rnum%3D1

and a friend told me when developing for smartdevice in vs.net I was using
compact framework. But as I said I don't know..

//Jan

That's a bit rubbish.

I was once involved in an eVB project, and I'm pretty sure we used MSXML
to evaluate XPATH expressions on a PDA. I wrote the synchronisation
software in C#, but I think I remember helping the eVB guy with XPATH
syntax.

You might be able to use MSXML via COM interop, but I think it's probably
simpler just to iterate the nodes and examine them.

--
Steve Walker

Nov 17 '05 #8
In message <eV************ **@TK2MSFTNGP12 .phx.gbl>, "Richard Blewett
[DevelopMentor]" <ri******@NOSPA Mdevelop.com> writes
You might be able to use MSXML via COM interop, but I think it's
probably simpler just to iterate the nodes and examine them.
Of course - that would require COM interop to be supported ;-)


<Homer>Doh!</Homer>

--
Steve Walker
Nov 17 '05 #9
In message <r2************ **********@news .easynews.com>, janhm
<no******@this. adr> writes
That's a bit rubbish.
and a friend told me when developing for smartdevice in vs.net I was using
compact framework. But as I said I don't know..


You are, and those XPATH methods aren't supported. I think you'll have
to resort to brute force and ignorance.

--
Steve Walker
Nov 17 '05 #10

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

Similar topics

3
1410
by: Shawn | last post by:
Hi. I have an XML file that looks like this: <?xml version="1.0" encoding="utf-16"?> <Transfer> <Config xmlns="http://www.mysite.com/Transfer/"> <site>NY</site> </Config> </Transfer> I'm trying to get the value of "site", but I'm having some trouble with it.
1
2627
by: Mario Crevits | last post by:
My name is Mario Crevits, I'm from Belgium (Roeselare) and I'm working with Access97 for several years now. We are in an Access97-2000 migration project. I'm writing a wizard for the end-users to automatically find and convert their Access97 databases on a specific drive. I want to convert the databases through VBA : 1. create an empty...
2
3148
by: manmit.walia | last post by:
Hello All and Thank You for your time, I am stuck on this exception handleing error. The problem is that when I run my application the application works perfect but sometimes, I get this error. I do not know where it is causing it but my guess would be something with the function below. Any help would be greatfull, as this would be a learning...
5
3252
by: ttomes | last post by:
I'm trying to parse a XML file and extract a few data elements. I'm having trouble extracting the exact elements. I get the entire content of the XML file in the text box currently. I can't figure out how to just get the elements/attirbutes that I want. This is being done in Visual Web Developer Express. The code I have so far is:
4
2744
by: georges the man | last post by:
hey guys, i ve been posting for the last week trying to understand some stuff about c and reading but unfortunaly i couldnt do this. i have to write the following code. this will be the last time i ask for an entire code or u can give me the outine of what to do and i ll do it by myself. the description is the following: the program...
2
3133
by: James Fifth | last post by:
Hello and God Bless, I am stumped trying to get a simple xml database replacing certain data with other data programmatically. This is what my xml looks like. **************************************** <Root_Element> <Topic index="1"> <Sub_Topic> <Notes></Notes>
4
54089
by: Hooyoo | last post by:
I have a XML file as following: <configuration> <MachineList> <Machine Name="mycomputer"/> </MachineList> </configuration> How can I program to change "mycomputer" to "somecomputer"? Any comments will be appreciated.
0
2883
by: Rene Goris | last post by:
Hi all, I am trying to add meta:resourcekey's to database programmatically looping throug webcontrols, but i cann't read the 'meta:resourcekey' from the webcontrol. The 'meta:resourcekey' will not show up as attribute. How can i get the value of the 'meta:resourcekey' ? THE CODE: public string RetrieveControls(Control myControl){
1
1986
by: Robocop | last post by:
Having just started using C again after some years off, i've been stumped by a problem i think someone more experienced could probably solve pretty easily. I have these 4 objects (vectors), and i want to find a combination of these 4 objects into two pairs, where the sum of a specific attribute of each vector in each pair comes closest to...
0
7459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7393
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...
0
7803
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7411
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7749
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...
0
5965
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...
1
5322
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...
0
4942
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...
0
3444
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...

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.