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

return a name of a node in C#

hello, I have an xml file and I want to check if the string input in a textbox exist in a node but I dont know what to do.

- For example:
<equal>
<hdd>HardDiskType></hdd>
<hdd>HDD</hdd>

</equal>

a) When I input HDD or HardDiskType in the textbox, the string will match and return true
b) When I input a different string, like "123", it will obviously not match with any string in the tree and therefore return false

A little more difficult problem:
when a) occured, the system will return the name of the father node (in this example it will be "equal")

Thanks in advance.
Dec 16 '08 #1
8 2575
Dormilich
8,658 Expert Mod 8TB
sorry, I'm not # enough for C#. though I can help with XPath expressions.

regards
Dec 16 '08 #2
well, part of my problem is dealing with xpath (which I'm pretty clueless, since I only know some basic XML), so please help me create a proper xpath :D
Dec 16 '08 #3
Dormilich
8,658 Expert Mod 8TB
explain the xpath problem (or what you want the xpath to do) and we'll get it on.
Dec 16 '08 #4
thanks, for example: i want to create a xpath that return the tag name, uh, like return "hdd" when input HardDiskType or HDD; if possible, return "equal" also

<equal>
<hdd>HardDiskType></hdd>
<hdd>HDD</hdd>
</equal>
Dec 16 '08 #5
Dormilich
8,658 Expert Mod 8TB
let's cut it down into pieces:
@Force88
local-name(*)
@Force88
*[text() = 'HDD' or text() = 'HardDiskType']
@Force88
-- not at the same time (only when you have a node-set as return)
parent::*

now for the homework: put it all together:

regards
Dec 16 '08 #6
Frinavale
9,735 Expert Mod 8TB
What version of the .NET framework are you using?
Dec 16 '08 #7
thanks Dormilich, my problem is now solved.

Im using .Net ver 3.0, included in Visual Studio 2008

by the way, how can I populate the file in a dropdownlist ? I create a xmldatasource, bind it to the dropdownlist, the list did show correct lines accord to the nodes in xml file, but it didnt show the value ("hdd" or "HardDiskType") but "System.blah blah blah instead
Dec 16 '08 #8
Frinavale
9,735 Expert Mod 8TB
I was going to suggest looking into using LINQ to help you but you seem to have solved your problem.

As for the DropDownList displaying the text, it looks like you can provide an XSL to the XmlDataSource to transform the XML data before it is displayed by the DropDownList.

You can also filter the data by setting the XmlDataSource's XPath property to an XPath expression to filter the XML data after the data is loaded and transformed.

-Frinny
Dec 16 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Daniel Hansen | last post by:
I'm sure I saw this somewhere but can't remember where and can't find it now... Is there a PHP function or global variable that will return name of the calling function? I want to do this for...
0
by: Mike | last post by:
Hello All, I wrote a function that will create a file system directory for my web application and display it in the IE Treeview control. Everything wrotes great! What I'm having trouble with is...
3
by: Melissa | last post by:
I have forty-two small subforms on a form. I need help with the code that will return the name of the subform control when I click on any subform control. I know how to select all the subform...
2
by: Jeremy | last post by:
Hello, Is anyone aware of a function that will return the name of all forms contained in a database WITHOUT opening them. I have code that does it (posted below), but you must open and close the...
3
by: Greg Merideth | last post by:
This piece of code creates a fault at the attempt to get the modulename of the process when (in server2k or xp) the code gets to the "System" prcoess. Process machineProcesses =...
3
by: =?Utf-8?B?QW1pcg==?= | last post by:
Hi I am trying to extract a node from the following XML doc <?xml version='1.0' encoding='UTF-8'?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"...
0
by: Matthew Peter | last post by:
For example, how do I get this to work? def func(): print "This is", __?__ return __caller__ def echo(): print "This is ", __?__ return func()
0
by: max.vit | last post by:
I am trying to retrieve the user name (network login) of clients running a local Access DB. We use Access 2000 / 2003 and Windows XP SP 2. I have used 2 different ways to access this information...
4
by: MattGaff | last post by:
I have a list of images in the resource file of a VB project and a particular picture box on my form gets populated with an image depending on certain conditions: picNotify.Image = My.Resources. ...
0
by: Charles Ndethi | last post by:
Here is sample pseudocode to capture the logic. Attached is the sql export. if ( lab_sessiontime.Start_time > NOW()) then lab is free for Start_time - NOW() minutes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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...

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.