Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML with VB6 (Newbee) 1

Status
Not open for further replies.

Periko

Programmer
Feb 24, 2003
134
BE
Hello,

I'm rather new in this. When I have different nodes, how can I position myself on the right place and read out the data? I'm messing around with elements, nodes and nodelists, but don't get anywhere......

-Job
-Right
-order
<supcode="xxx" procode="yyy"/>

How can I read out the supcode from right, not risking i'm taking them from left ?
Sorry, seems stupid however, but it's complete new for me.
I'm using the xml 6.0 in the references from vb6.
Loading the document is ok, but that's all...

Thx for any help...
Periko...
 
Yes, it is a changing default setting of different version.

[1] if you use core service 3.0, then you have the least work.
[tt]
set XD=createobject("msxml2.domdocument.3.0")

Set xNode = XD.createProcessingInstruction("xml", "version ='1.0' encoding = 'utf-8'")

XD.appendChild xNode
Set xNode = Nothing

Set rElem = XD.createElement("Root")
With rElem
.setAttribute "xmlns", " .setAttribute "aaa", "value1"
.setAttribute "bbb", "value2"
End With
Set XD.documentElement = rElem

Set xElem = XD.createElement("FirstChild")
rElem.appendChild xElem

Set xElem1 = XD.createElement("ChildOfFirstChild")
xElem.appendChild xElem1
[/tt]
[2] For version 4.0 up, the default behaviour has changed. My last post is certainly defective (I was using version independent progid which is pointing to 3.0, but when posting, I added 4.0 which need more care). This is how to handle it with default namespace.
[tt]
set XD=createobject("msxml2.domdocument.4.0") '4.0,5.0,6.0

Set xNode = XD.createProcessingInstruction("xml", "version ='1.0' encoding = 'utf-8'")

XD.appendChild xNode
Set xNode = Nothing

Set rElem = XD.createElement("Root")
With rElem
.setAttribute "xmlns", " .setAttribute "aaa", "value1"
.setAttribute "bbb", "value2"
End With
Set XD.documentElement = rElem

Set xElem = XD.create[blue]Node(1,"FirstChild","[/blue]
rElem.appendChild xElem

Set xElem1 = XD.create[blue]Node(1,"ChildOfFirstChild","xElem.appendChild xElem1
[/tt]
The idea is every time you want the default namespace to be inherited, you need to use createNode with the info of the namespace being specified.
 
P E R F E C T !

I owe you a lot, Tsuji...

Periko...
 
Hello Tsuji,

I nearly finalized my project. Just one last question ...

When you get a value from an attribute, how can i write this directly to a file ?

I've seen this once in a vb.net application, but i'm not sure if this exists in VB6 ?

If so, how to do this ?

Kind regards...
Pedro...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top