473,473 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

"filtering" an XML file

Hello,

I have the following basic XML file:

<ProductX>
<Settings>
<FormA>
<TextBox1>
<value>ABC</value>
</TextBox1>
<TextBox2>
<value>XYZ</value>
</TextBox2>
<FormA>
<FormB>
<TextBox1>
<value>123</value>
</TextBox1>
</FormB>
</Settings>
</ProductX>

I want to be able to "filter" the XML on the load of a
form so that I only have the Nodes with the FormA tags. I
cannot work out how to do this. Any help would be
appreciated.

Thanks in advance,

Felciity
Nov 11 '05 #1
4 1465
XmlDocument doc = new XmlDocument();
doc.Load("yourxmldoc.xml");

XmlNodes xNodes = doc.SelectNodes
("//ProductX//Settings//FormA");

That should do it.

-Demetri
-----Original Message-----
Hello,

I have the following basic XML file:

<ProductX>
<Settings>
<FormA>
<TextBox1>
<value>ABC</value>
</TextBox1>
<TextBox2>
<value>XYZ</value>
</TextBox2>
<FormA>
<FormB>
<TextBox1>
<value>123</value>
</TextBox1>
</FormB>
</Settings>
</ProductX>

I want to be able to "filter" the XML on the load of a
form so that I only have the Nodes with the FormA tags. Icannot work out how to do this. Any help would be
appreciated.

Thanks in advance,

Felciity
.

Nov 11 '05 #2
Felicity wrote:
I want to be able to "filter" the XML on the load of a
form so that I only have the Nodes with the FormA tags. I
cannot work out how to do this. Any help would be
appreciated.


It can be done in many ways: XSLT, customized XmlTextReader, XPath selection
over XmlDocument or XPathDocument etc. Which one do you prefer?
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #3
Hello,

I am interested in finding out about the XPath method. But, I may be
interested in finding out about other methods also. Can you give me
some indication of a resource that has some decent code samples and
explanations about these methods?

Thanks in advance,

Felicity

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 11 '05 #4
felicity h wrote:
I am interested in finding out about the XPath method.
XPath approach is to load your XML document into XPath navigable object
(XmlDocument, XPathDocument, XmlDataDocument), and then query appropriate
portion of data:
XmlDocument doc = new XmlDocument();
doc.Load("foo.xml");
XmlNode formA = doc.SelectSingleNode("/ProductX/Settings/FormA");
But, I may be
interested in finding out about other methods also. Can you give me
some indication of a resource that has some decent code samples and
explanations about these methods?

MSDN is the best resource. Read about XmlReader - you can create customized
filtering XmlReader, that's going to be the most effective, but not simplest
solution.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #5

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

Similar topics

15
by: Jordan Rastrick | last post by:
First, a disclaimer. I am a second year Maths and Computer Science undergraduate, and this is my first time ever on Usenet (I guess I'm part of the http generation). On top of that, I have been...
1
by: David Furey | last post by:
Hi I have an XML documnet and a XSLT document as shown below THe XSLT document brings back a filtered docmument that has the VendorName that starts with a particular sub-string This works as...
0
by: Frithiof Andreas Jensen | last post by:
I am writing an application that does a lot of filtering of much data through a sequence of filters. After some thinking and wasting a lot of time with an object oriented design with GUI and...
9
by: Dennis Ruppert | last post by:
Greetings This is rather ambitious: I have a split database that contains many different reports. I have a form that the end user launches the reports from. They select the report criteria...
1
by: S. van Beek | last post by:
Dear reader, How can I filter a numeric field with Like as criteria in a query. To filter a numeric field with <10 as criteria this will com back with the result of those records for which...
16
by: Andrew Baker | last post by:
I am trying to write a function which provides my users with a file filter. The filter used to work just using the VB "Like" comparision, but I can't find the equivilant in C#. I looked at...
9
by: Anneybo | last post by:
Alright, I give up! I'm asking the experts. I have created a database that calculates PTO for employees. I need to be able to cache the report by user entered dates and specific employee names. I...
3
by: cberthu | last post by:
Hi all, Is it possible to have two connects in the same rexx script to different DB's? I have to get data form on DB (with specifics selects and filter out some values with RExx) and save the...
6
by: karen987 | last post by:
I have a webpage called "topicview.asp" on a news website with ASP pages, it's a simple news publishing software. You add the news from the Admin section and all the details are stored in a...
0
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,...
0
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...
0
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,...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.