Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Why XmlNode.Name get node name and its first attribute together?

Reply
Thread Tools

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

 
 
=?Utf-8?B?ZGF2aWQ=?=
Guest
Posts: n/a
 
      03-12-2007
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Its a bird, its a plane, its.. um, an Attribute based System? thunk Ruby 14 04-03-2010 10:08 AM
Its a bird, its a plane, its.. um, an Attribute based System? thunk Ruby 0 04-01-2010 10:25 PM
[XSLT] Select node by attribute with value from an attribute of its self Stefan_W XML 1 11-05-2008 10:50 AM
obtain element name, or attribute and value of the document name itself, and some elemnts and attributes from an ancestor or the node itself using xquery Jeff Kish XML 4 10-30-2008 05:47 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM



Advertisments