1 Attachment(s)
Missing XML Name Information???
I've put together the following code that reads an XML file into an XML Document, and iterating thru each node in the document, I'm placeing the node's name and associated value into a treeview:
VB Code:
Private Sub Button1_Click_1 (ByVal sender As System.Object, ByVal e As System.EventArgs) _[i]edit[/i]
Handles Button1.Click
Dim MyBoo As Boolean
Dim MyNode As XmlNode
Dim FitN As TreeNode
Dim rootNode As TreeNode
Dim MyStockXML As New Xml.XmlDocument()
MyStockXML.Load ("c:\psip_stocklibrary.xml")
TreeView1.Visible = False
Application.DoEvents()
rootNode = TreeView1.Nodes.Add("Media")
TreeView1.SelectedNode = rootNode
Call FILLTreeV(MyStockXML, rootNode)
TreeView1.Visible = True
End Sub
Public Sub FILLTreeV(ByVal mNode As XmlNode, ByVal pNode As TreeNode)
Dim FitN As TreeNode
Dim selNode As TreeNode
Dim MyChildNode As XmlNode
For Each MyChildNode In mNode '.ChildNodes
FitN = New TreeNode(MyChildNode.Name & " " & MyChildNode.Value)
pNode.Nodes.Add (FitN)
If MyChildNode.HasChildNodes = True Then
FILLTreeV(MyChildNode, FitN)
End If
Next
End Sub
Now, the XML text in the file "c:\psip_stocklibrary.xml" looks like:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<stockLibrary xmlns="http://www.xerox.com/psip/app/media/StockLibrary" _edit
xmlns:vudu="vudu" vudu:class="psip.app.media.xml.StockLibraryFormat" _edit
vudu:serial="-1141390230395564101_0.2.1">
<nextStockID value="376" />
<media>
<name>(p005426_19p5x14p33)</name>
<predefinedColor>MEDIA_COLOR_WHITE</predefinedColor>
<weight>280</weight>
<sidesCoated>0</sidesCoated>
<coatingType>MEDIA_COATING_TYPE_NONE</coatingType>
<thickness>334</thickness>
<finish>MEDIA_FINISH_REGULAR</finish>
<xeroxDefined>false</xeroxDefined>
<rmlVersion />
<comments></comments>
<hidden>false</hidden>
yadayadayada...
And my resulting treeview looks like this:
http://www.vbforums.com/attachment.p...postid=1691551
So what I don't understand is:
the first node below the root is named xml version="1.0" encoding="UTF-8" which is seen in the file as:
Code:
<?xml version="1.0" encoding="UTF-8"?>
The next node, seen as stock Library in the picture, has as its text in the file:
Code:
<stockLibrary xmlns="http://www.xerox.com/psip/app/media/StockLibrary" _edit
xmlns:vudu="vudu" vudu:class="psip.app.media.xml.StockLibraryFormat" _edit
vudu:serial="-1141390230395564101_0.2.1">
and the third node, seen as nextStockID, has the following text line in the file:
Code:
<nextStockID value="376" />
So:
[list=a][*]What happened to the bracketing question marks in the first treeview node?[*]Why is the second node only named stockLibrary? What happened to all of that http and vudu info as seen in its file line?[*]Whats up with that value="376" in the file for nextStockID? Why doesn't it show up in the TreeView?[*]The node that is called "name" contains a subnode identified as #text (p005426_19p5x14p33). Isn't that SubNode supposed to be the Value of the name node {minus the #text bit}, since its structure in the file is: <name>(p005426_19p5x14p33)</name> ??? [/list=a]
:confused:
-Lou