this is my XML data....<ROOT>biodata <NAME>nix</NAME> <LAST>patel</LAST><WORK>mywork <W>x</W> <W>y</W></WORK></ROOT>
i can store this data in TreeView..using code example given in MSDN. but it also shows tags as nodes...that i dont want.
it shows like... ROOT
|-----biodata
|-----NAME
|------nix
|-----LAST
|------patel
|-----WORK
|-------mywork
|-----W
|-----x
|-----W
|-----y
---------------------------------------------------------
And i need only data instead of showing TAGS....like this
biodata
|-----nix
|-----patel
|-----mywork
|------x
|------y
So please..give me solution..here is the code from MSDN.
-----------------------------------------------------------------------
private void button1_Click(object sender, EventArgs e)
{
try
{
// SECTION 1. Create a DOM Document and load the XML data into it.
XmlDocument dom = new XmlDocument();
dom.Load(Application.StartupPath + "\\Sample.xml");
// SECTION 2. Initialize the TreeView control.
treeView1.Nodes.Clear();
treeView1.Nodes.Add(new TreeNode(dom.DocumentElement.Name));
TreeNode tNode = new TreeNode();
tNode = treeView1.Nodes[0];
// SECTION 3. Populate the TreeView with the DOM nodes.
AddNode(dom.DocumentElement, tNode);
treeView1.ExpandAll();
}
catch (XmlException xmlEx) { MessageBox.Show(xmlEx.Message); }
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
private void AddNode(XmlNode inXmlNode, TreeNode inTreeNode)
{
XmlNode xNode;
TreeNode tNode;
XmlNodeList nodeList;
int i;
// Loop through the XML nodes until the leaf is reached.
// Add the nodes to the TreeView during the looping process.
if (inXmlNode.HasChildNodes)
{
nodeList = inXmlNode.ChildNodes;
for(i = 0; i<=nodeList.Count - 1; i++)
{
xNode = inXmlNode.ChildNodes
;
inTreeNode.Nodes.Add(new TreeNode(xNode.Name));
tNode = inTreeNode.Nodes
;
AddNode(xNode, tNode);
}
}
else
{
// Here you need to pull the data from the XmlNode based on the
// type of node, whether attribute values are required, and so forth.
inTreeNode.Text = (inXmlNode.OuterXml).Trim();
}
}

Need help(urgent) regarding showing XML data in TreeView.
Deepak83
MyXmlNode.InnerXml would give you "content & sons"
or MyXmlNode.InnerText will give you "content & sons"
If you used OuterXml it would give you <TAG>content & sons></TAG>
They are creating an extra node. See my first post.
antony leo
assassin316
may be i am wrong..
but...the data between <TAG>data</TAG>..is not available in any property of node...
can u tell me in detail..or can u change the code..PLease