|
-
Feb 28th, 2002, 02:41 AM
#1
Thread Starter
Hyperactive Member
XML with VB
Hello can some one help me with this I need to get a XML pages code and display it in some labels
Code:
<!---FileName: UserList.xml---!>
<?xml version="1.0" encoding="ISO-8859-1"?>
<note ID="001">
<to>John</to>
<from>Jo</from>
<heading>Hello</heading>
<body>Some text Here<body>
</note>
<to> = lblTo
<From>=lblFrom
<header=lblHeader
<body>=lblBody
some one help me out please
-
Feb 28th, 2002, 01:21 PM
#2
Member
Sorry I can't help you with that one
-
Feb 28th, 2002, 01:30 PM
#3
add a reference to the Microsoft XML object
Code:
Dim xmlDoc As MSXML.DOMDocument
Dim xmlRoot As MSXML.IXMLDOMNode
Set xmlDoc = New MSXML.DOMDocument
xmlDoc.async = False
xmlDoc.Load App.Path & "\system\ServerConfig.xml"
Set xmlRoot = xmlDoc.selectSingleNode("VegaCOMM/Config")
txtServerName.Text = xmlRoot.selectSingleNode("ServerName").Text
txtAdminName.Text = xmlRoot.selectSingleNode("AdminName").Text
txtMaxClients.Text = xmlRoot.selectSingleNode("MaxUsers").Text
that is for a document that looks like this
Code:
<VegaCOMM>
<Config>
<ServerName>VegaCOMM Public Server</ServerName>
<AdminName>Chris Andersen</AdminName>
<MaxUsers>50</MaxUsers>
<ForumMessageDays>15</ForumMessageDays>
<ServerNews>Welcome To The VegaCOMM Public Server</ServerNews>
</Config>
<BannedIPs>
<IP>333.45.33.21</IP>
<IP>567.77.34.6</IP>
</BannedIPs>
<HandleFilter>
<Handle/>
</HandleFilter>
</VegaCOMM>
now with your xml having this
<?xml version="1.0" encoding="ISO-8859-1"?>
you may have to cahnge one line to
Set xmlRoot = xmlDoc.firstChild.selectSingleNode("VegaCOMM/Config")
Hope this helps
-
Feb 28th, 2002, 03:58 PM
#4
Thread Starter
Hyperactive Member
Ya that will work thanks!! i know how to write to the file but how can i see if the data is alrdy in the file?
-
Feb 28th, 2002, 04:01 PM
#5
that is what my code does is read the file
-
Feb 28th, 2002, 05:25 PM
#6
Thread Starter
Hyperactive Member
Ok cool thanks will post when i get it to work
[edit]
with this
mlRoot = xmlDoc.selectSingleNode("VegaCOMM/Config")
would i have to do this
<note ID="001">
mlRoot = xmlDoc.selectSingleNode("note/ID=001")
or should i do like
<note>
<ID=001>
mlRoot = xmlDoc.selectSingleNode("note/ID=001")
Last edited by 308holes; Feb 28th, 2002 at 05:35 PM.
-
Feb 28th, 2002, 06:20 PM
#7
Thread Starter
Hyperactive Member
tryed that and im getting errors i dont think i have the XML control
VB Code:
Private Sub cmdRead_Click()
Dim xmlDoc As MSXML.DOMDocument
Dim xmlRoot As MSXML.IXMLDOMNode
Set xmlDoc = New MSXML.DOMDocument
xmlDoc.async = False
xmlDoc.Load App.Path & "C:\Documents and Settings\Owner\My Documents\MIC\first.xml"
Set xmlRoot = xmlDoc.selectSingleNode("note/ID=001")
'Set xmlRoot = xmlDoc.firstChild.selectSingleNode("note/ID=001")
txtName. Text = xmlRoot.selectSingleNode("Name").Text
End Sub
its telling me User-Definded type is nto definded for
Dim xmlDoc As MSXML.DOMDocument
Dim xmlRoot As MSXML.IXMLDOMNode
Last edited by 308holes; Feb 28th, 2002 at 06:30 PM.
-
Mar 1st, 2002, 09:30 AM
#8
refer to my PM to you about the control..
a note..
mlRoot = xmlDoc.selectSingleNode("note/ID=001")
would not work..just say note
mlRoot = xmlDoc.selectSingleNode("note")
ID=001 is an attribute of the note Node, not another Node below note
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|