469,915 Members | 2,652 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,915 developers. It's quick & easy.

Why XmlNode.Name get node name and its first attribute together?

When I create a tree view control from XML document, I use XmlNode.Name in
the node list iteration. But sometime, it is supposed that it got the element
name. But sometimes it got the element name and first attribute together.

For eaxmple, I use the following iteration code after creating the root from
DOM.DocumentElement.Name.
-----
private void AddNode2(XmlNode inXmlNode, TreeNode inTreeNode)
{
XmlNode xNode;
TreeNode tNode;
XmlNodeList xNodeList;
int i;

if(inXmlNode.HasChildNodes)
{
xNodeList = inXmlNode.ChildNodes;
for(i=0; i < xNodeList.Count; i++)
{
inTreeNode.Nodes.Add(new TreeNode(xNode.Name));
tNode=inTreeNode.Nodes[i];
AddNode(xNode, tNode);
}
}
else
{
inTreeNode.Text = inXmlNode.Name;
}
}
-----
Here is my XML file:
-------
<?xml version="1.0" encoding="utf-8"?>
<PA id="08-01-01">
<ST part="head" date="20040403">1
<SE desc="Scout">1
<IM>1</IM>
<IM>2</IM>
</SE>
<SE desc="Routine">2
<IM>1</IM>
<IM>2</IM>
<IM>3</IM>
<IM>4</IM>
</SE>
</ST>
</PA>
-------
My tree view looks like:
--------
PA
|---1
|---ST
|---1
|---SEScout
| |---1
| |---IM
| |---1
| IM
| |---2
|---SERoutine
| |---2
| |---IM
| |---1
................
----------

The XmlNode.Name return ST for <ST part="head" date="20040403">
but return SEScout for <SE desc="Scout"and SERoutine for <SE
desc="Routine">.
I do not know why.
Could any one here give a help?

Thanks

David
Mar 12 '07 #1
0 1074

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by David Elliott | last post: by
3 posts views Thread by Mahesh Devjibhai Dhola | last post: by
4 posts views Thread by The Kiddie | last post: by
5 posts views Thread by Paul | last post: by
1 post views Thread by andrej | last post: by
2 posts views Thread by Josema | last post: by
3 posts views Thread by Andy | last post: by
5 posts views Thread by =?Utf-8?B?VGhlIE1hbiBGcm9tIFNRTA==?= | last post: by
4 posts views Thread by CSharper | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.