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

Simple XML parsing question

Hi.

I am new to both C# and XML parsing. I simply want to find out if a
node contains other nodes, and if it does i want to do something with
it. How can i find out in a simple way that in the example below both
<data> and <moredata> contains other nodes? I have been using both the
XPathNavigator and the XMLNodeReader without finding a cleaver way of
doing this...

XML example:

<data>
<elem>val<elem>
<elem>val<elem>
<moredata>
<elem>val<elem>
</moredata>
</data>
Nov 16 '05 #1
2 1243
Vegard Beider wrote:
Hi.

I am new to both C# and XML parsing. I simply want to find out if a
node contains other nodes, and if it does i want to do something with
it. How can i find out in a simple way that in the example below both
<data> and <moredata> contains other nodes? I have been using both the
XPathNavigator and the XMLNodeReader without finding a cleaver way of
doing this...

XML example:

<data>
<elem>val<elem>
<elem>val<elem>
<moredata>
<elem>val<elem>
</moredata>
</data>


You can either use the XmlNode.HasChildNodes property or the
XmlNodeReader.IsEmptyElement property

--

Ed Courtenay
[MCP, MCSD]
http://www.edcourtenay.co.uk
Nov 16 '05 #2
Ed Courtenay <re*****************************@edcourtenay.co.uk > wrote in message news:<#0**************@TK2MSFTNGP11.phx.gbl>...
<data>
<elem>val<elem>
<elem>val<elem>
<moredata>
<elem>val<elem>
</moredata>
</data>


You can either use the XmlNode.HasChildNodes property or the
XmlNodeReader.IsEmptyElement property


I tried using the IsEmptyElement none of the above nodes are empty
since they have a value, i want to know if a node contains other
nodes..
Nov 16 '05 #3

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

Similar topics

10
by: george young | last post by:
For each run of my app, I have a known set of (<100) wafer names. Names are sometimes simply integers, sometimes a short string, and sometimes a short string followed by an integer, e.g.: 5, 6,...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
6
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am...
2
by: Ivan Demkovitch | last post by:
Hi! I'm trying to parse RSS news feed with code as simple as possible. Simple XML: <?xml version="1.0"?> <rss version="2.0"> <channel> <item>
4
by: Wardeaux | last post by:
All, this XML is killing me... I'm new to XML, all I want to do is parse an XML string so that I can read the values... Mystr = "<A1><B1><C1>myC1</C1><C2>myC2</C2></B1><B2>myB2</B2><A1>" All...
50
by: Doug | last post by:
I can't imagine this is that hard but I'm sure having a struggle finding it. How do I convert a value like "111403" do a DateTime variable in DotNet (i.e. 11/14/2003)?
7
by: db | last post by:
Hi@all Just got a comparison problem with javascript. I want to compare : document.getElementById(currentID).getAttribute("style") with a string, e.g: "background-color: lightgreen;" They...
6
by: Jacob Rael | last post by:
Hello, I have a simple script to parse a text file (a visual basic program) and convert key parts to tcl. Since I am only working on specific sections and I need it quick, I decided not to...
9
by: Pygmalion | last post by:
I have found dozen of useful PHP counters on the web. However, nobody is working for my web pages, since administrator does not want to enable the possibility that PHP could be called from HTML. ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
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...
0
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...

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.