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.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
From Sun 30 Nov 2008 16:07:12 -0600 (CST)
Delivered-To: listarchive@realsoftware.com
Received: by 10.143.98.10 with SMTP id a10cs277291wfm;
Sun, 30 Nov 2008 14:08:43 -0800 (PST)
Received: by 10.65.204.2 with SMTP id g2mr10928315qbq.45.1228082923251;
Sun, 30 Nov 2008 14:08:43 -0800 (PST)
Return-Path: <realbasic-nug-bounces@lists.realsoftware.com>
Received: from advanced107.inmotionhosting.com (advanced107.inmotionhosting.com
[74.124.194.228])
by mx.google.com with ESMTP id p6si7287631qbp.17.2008.11.30.14.08.41;
Sun, 30 Nov 2008 14:08:43 -0800 (PST)
Received-SPF: neutral (google.com: 74.124.194.228 is neither permitted nor
denied by best guess record for domain of
realbasic-nug-bounces@lists.realsoftware.com) client-ip=74.124.194.228;
Authentication-Results: mx.google.com; spf=neutral (google.com: 74.124.194.228
is neither permitted nor denied by best guess record for domain of
realbasic-nug-bounces@lists.realsoftware.com)
smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Received: from localhost ([127.0.0.1] helo=advanced107.inmotionhosting.com)
by advanced107.inmotionhosting.com with esmtp (Exim 4.69)
(envelope-from <realbasic-nug-bounces@lists.realsoftware.com>)
id 1L6uRd-0000uq-62; Sun, 30 Nov 2008 14:07:13 -0800
Received: from boundless.dns-defender.com ([69.65.40.13])
by advanced107.inmotionhosting.com with esmtps (TLSv1:AES256-SHA:256)
(Exim 4.69) (envelope-from <fargo@rpgportland.com>)
id 1L6uRb-0000uh-Jp for realbasic-nug@lists.realsoftware.com;
Sun, 30 Nov 2008 14:07:11 -0800
Received: from localhost ([127.0.0.1] helo=rpgportland.com)
by boundless.dns-defender.com with esmtpa (Exim 4.69)
(envelope-from <fargo@rpgportland.com>) id 1L6uRc-0000A2-AQ
for realbasic-nug@lists.realsoftware.com;
Sun, 30 Nov 2008 16:07:12 -0600
Received: from 198.107.161.80 ([198.107.161.80])
(SquirrelMail authenticated user fargo@rpgportland.com)
by rpgportland.com with HTTP; Sun, 30 Nov 2008 16:07:12 -0600 (CST)
Message-ID: <54194.198.107.161.80.1228082832.squirrel@rpgportland.com>
In-Reply-To: <49330768.7070604@stny.rr.com>
References: <49330768.7070604@stny.rr.com>
Date: Sun, 30 Nov 2008 16:07:12 -0600 (CST)
Subject: Re: XML Questions
From: fargo@rpgportland.com
To: "REALbasic NUG" <realbasic-nug@lists.realsoftware.com>
User-Agent: SquirrelMail/1.4.13
MIME-Version: 1.0
X-Priority: 3 (Normal)
Importance: Normal
X-AntiAbuse: This header was added to track abuse,
please include it with any abuse report
X-AntiAbuse: Primary Hostname - boundless.dns-defender.com
X-AntiAbuse: Original Domain - lists.realsoftware.com
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - rpgportland.com
X-Source:
X-Source-Args:
X-Source-Dir:
X-BeenThere: realbasic-nug@lists.realsoftware.com
X-Mailman-Version: 2.1.10
Precedence: list
Reply-To: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: realbasic-nug-bounces@lists.realsoftware.com
Errors-To: realbasic-nug-bounces@lists.realsoftware.com
X-AntiAbuse: This header was added to track abuse, please include it with any
abuse report
X-AntiAbuse: Primary Hostname - advanced107.inmotionhosting.com
X-AntiAbuse: Original Domain - realsoftware.com
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - lists.realsoftware.com
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>
|