Actually, I think that XML is more trouble than it's worth in this case.
Charles Yeomans
On Nov 30, 2008, at 5:47 PM, Tom Russell wrote:
Thanks to Fargo and Charles I have some direction to go in.
I have to agree with Fargo that the way the xml file is laid out
makes it more trouble trying to work with. I think the simple way he
describes is the easier way to parse what you need.
Thanks.
fargo@rpgportland.com wrote:
I have an xml file that looks like this:
<?xml version="1.0" encoding="utf-8"?>
<config>
<node id="lastDownload" text="Pj48PkE8Pz09RQ" />
<node id="applicationVersion" text="QDtEOnd6" />
<node id="applicationBuild" text="QDtEOnd6" />
<node id="localFilePath" text="" />
<node id="sitePath" text="dYGBfUc8PHtygT+BfXo7cHx6PA" />
<node id="timeToLive" text="P0I" />
<node id="retries" text="QA" />
</config>
While I have done some xml before with RB this one is giving me some
grief.
I have some code written:
Dim FI As FolderItem
Dim TIS as TextInputStream
FI = GetFolderItem("config.xml")
Dim FName,loginfo,oneCell as String
Dim root_count,i,count_po As Integer
Dim node as XMLNode
If FI.Exists() Then
TIS = FI.OpenAsTextFile()
loginfo=TIS.ReadAll
dim xd As new XMLDocument
xd.LoadXML(loginfo)
root_count = xd.DocumentElement.childCount
For i = 0 to root_count - 1
node = xd.DocumentElement.Child(i)
Next
But I really am not sure how to grab the things I need. I set some
properties in my app for the nodes listed in the xml and would
like to
assign these by the text or values listed.
Could someone point me in the right direction, I would appreciate
it.
Thanks.
Wouldn't it be easier if your XML was more like this-
<?xml version="1.0" encoding="utf-8"?>
<config>
<lastDownload>Pj48PkE8Pz09RQ</lastDownload>
<applicationVersion>QDtEOnd6</applicationVersion>
</config>
And so on?
Then Select Case on the node.Name and use node.firstchild.value to
get the
textnode? I'm not 100% sure on the firstchild part being right for
you,
not without actually running through it.
That's how I did it with my Witch Hunt app anyway. It seems to work
well,
though you'll have a different child depth since you didn't use a
<root>
tag and I did. Feel free to look at it, if you think it'll help-
http://www.risingphoenixgroup.com/dls/privy/witchhunt_src.zip
The XML loading bit is in the grimoire class method loadIndex.
Best of luck,
Fargo
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|