Re: read XML & display in a tree view -
12-28-2005
, 08:06 AM
You'll probably get a better response if you post this on one of the
language groups (microsoft.public.dotnet.languages/vb or
microsoft.public.dotnet.languages/csharp).
You could use the System.Xml.XmlReader class, to read through the
elements in the XML file. First, set up a root node on your treeview,
and make a reference to it, called something like TreeCursor. Then
whenever you reach an Element node in the XML, add a new child-element
to your TreeCursor node with the title equal to the XmlReader's name
property. Now, if the XmlNode is a block node (has a closing tag), set
the cursor to point to the tree node you've added, and continue; if
not, just carry on parsing. Then, if you reach an EndElement node in
the XML, you can set TreeCursor to point to its parent, and continue
parsing. At the end of the file, if it's well-formed, TreeCursor should
end up pointing back to the root element. |