| View previous topic :: View next topic |
| Author |
Message |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Mon Jan 07, 2008 2:58 am Post subject: VDS6 - problems reading the data in a XML file |
|
|
VDS6
This is not a bug, probably something I'm doing wrong.
I seem to be having problems reading the data in a XML file.
I get an runtime error 2 on the INFO %B
INFO %A works fine...
| Code: | INIFILE OPEN,C:\ZZZ\test_cfg[1].xml, XML
%A = @INIREAD(cfg,)
%B = @INIREAD(cfg,settings)
INFO %A
INFO %B
INIFILE CLOSE |
Below is a view of the example file in notepad:
| Code: | <cfg>
<levelList>
<level icons='6' clearAll ='0' clearRow ='0' rareIcon = '0' levelTime = '40000' moveTime = '3000' layout='1111111111111111111111111111111111111111111111111111111111111111' />
<level icons='7' clearAll ='0' clearRow ='0' rareIcon = '3' levelTime = '37500' moveTime = '2900' layout='1111111111111111111111111112211111122111111111111111111111111111' />
<level icons='7' clearAll ='0' clearRow ='0' rareIcon = '3' levelTime = '35000' moveTime = '2800' layout='1111111111111111112111111112211111122111111112111111111111111111' />
<level icons='8' clearAll ='0' clearRow ='0' rareIcon = '3' levelTime = '32500' moveTime = '2500' layout='1111111111111111112112111112211111122111112112111111111111111111'/>
<!-- introduce rares-->
<level icons='8' clearAll ='0' clearRow ='2' rareIcon = '3' levelTime = '30000' moveTime = '2250' layout='1111111111111111112222111122221111222211112222111111111111111111'/>
<level icons='8' clearAll ='0' clearRow ='2' rareIcon = '3' levelTime = '27500' moveTime = '2000' layout='1111111111111221112222211122221111222211122222111221111111111111'/>
<level icons='8' clearAll ='0' clearRow ='2' rareIcon = '3' levelTime = '25000' moveTime = '1800' layout='1111111112211221122222211122221111222211122222211221122111111111'/>
<level icons='8' clearAll ='0' clearRow ='2' rareIcon = '3' levelTime = '22500' moveTime = '1600' layout='1111111112222221122222211222222112222221122222211222222111111111' />
<level icons='8' clearAll ='0' clearRow ='2' rareIcon = '3' levelTime = '20000' moveTime = '1400' layout='1112211112222221122222212222222222222222122222211222222111122111' />
<!-- introduce clear all-->
<level icons='9' clearAll ='2' clearRow ='0' rareIcon = '3' levelTime = '17500' moveTime = '1200' layout='2222222222222222222222222222222222222222222222222222222222222222'/>
<level icons='9' clearAll ='2' clearRow ='0' rareIcon = '3' levelTime = '15000' moveTime = '1100' layout='2222222222222222222222222223322222233222222222222222222222222222'/>
<level icons='9' clearAll ='2' clearRow ='0' rareIcon = '3' levelTime = '12500' moveTime = '1000' layout='2222222222222222223333222233332222333322223333222222222222222222'/>
<level icons='9' clearAll ='2' clearRow ='0' rareIcon = '3' levelTime = '10000' moveTime = '900' layout='2222222223333332233333322333333223333332233333322333333222222222'/>
<level icons='9' clearAll ='2' clearRow ='0' rareIcon = '3' levelTime = '10000' moveTime = '700' layout='2223322223333332233333323333333333333333233333322333333222233222'/>
<level icons='9' clearAll ='2' clearRow ='0' rareIcon = '3' levelTime = '10000' moveTime = '500' layout='3333333333333333333333333333333333333333333333333333333333333333'/>
</levelList>
<points base='5' clearAll = '25' clearROW = '30' super = '50' rare = '500' maxRares = '6' rareID ='10' crysLength = '4' superLength ='5' />
<settings col ='8' row = '8' match = '3' burstTime ='12' timerFrequency ='33' tileSize = '50' hintTime = '6000' />
<download link='http://www.test.com/'/>
</cfg> |
Any suggestions is welcomed, Thanks..
|
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Mon Jan 07, 2008 5:41 am Post subject: |
|
|
The XML option with INIFILE OPEN just means that it will read XML tags for the "Section" and "Keyname" values.
Try this; create the following files:
Test.ini:
| Code: | [Settings]
col=8
row=8
match=3
burstTime=12
timerFrequency=33
tileSize=50
hintTime=6000 |
Test.xml:
| Code: | <settings>
<col>8</col>
<row>8</row>
<match>3</match>
<burstTime>12</burstTime>
<timerFrequency>33</timerFrequency>
<tileSize>50</tileSize>
<hintTime>6000</hintTime>
</settings> |
Put Test.dsc in the same path as the other two:
| Code: | REM TEST.DSC
INIFILE OPEN,Test.ini
%A = @INIREAD(Settings,)
%B = @INIREAD(Settings,col)
INFO %A
INFO %B
INIFILE CLOSE
INIFILE OPEN,Test.xml, XML
%A = @INIREAD(Settings,)
%B = @INIREAD(Settings,col)
INFO %A
INFO %B
INIFILE CLOSE
|
You should get the same results for each file.
This is as deep as @INIFILE() will read.
To go deeper you need to look at "XMLDOC" , "@XMLDOC()" and "LIST SELECT" in the helpfile.
The way your XML file is wittten it needs to be treated like a database instead of an INI type file.
Regards,
Aslan
|
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Mon Jan 07, 2008 8:45 am Post subject: |
|
|
Thats what I was thinking too, guess I'll have to tinker with the XMLDOC stuff.
But below VDS6 HELP was what fooled me:
[VDS6] If <key name> is null then the function returns a carriage-return delimited string containing all the values in <section name>.
It should show everything by the way it states, oh well.
I tryed @NEW() command too, didnt show anything, or I couldnt figure out how to get the list of items
Thanks Asian
|
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Mon Jan 07, 2008 2:11 pm Post subject: |
|
|
Vtol,
I am looking at your XML sample and all I see are attributes to the elements. I do not actually see any values for the elements. Hence the reason the INIFILE command/function is probably not working. You will need to use @XMLDOC(VALUES) with the path and the Attribute names your interested in. I am still trying to figure out what implementation of XPath VDS 6 XML parser uses.
| Quote: |
Returns a string containing the specified values and attributes stored at <path>, delimited using the current fieldsep character. Attribute names must be prefixed by “@” (in quotes to prevent VDS treating it as a function.) OK is false if path does not exist.
|
I have not had a chance to verify the code below but going by the help file it should work. I will try to validate it later.
| Code: |
XMLDOC LOADFILE,1,C:\ZZZ\test_cfg[1].xml
%%Icons = @XMLDOC(1,VALUES,/cfg/levelList/level,"@icons")
Info %%Icons@CR()
|
_________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
ed1 Commercial Research


Joined: 25 Sep 2001 Posts: 32
|
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Mon Jan 07, 2008 8:46 pm Post subject: |
|
|
DragonSphere I tried the XMLDOC stuff yesterday and never had any succsess seeing the values in a INFO view.
I tried the example like below:
| Code: | LIST create,1
XMLDOC LOADFILE,1,C:\ZZZ\test_cfg[1].xml
%%Icons = @XMLDOC(1,VALUES,/cfg/levelList/level,"@icons")
Info %%Icons@CR()
LIST close,1 |
But had the error below:
43
Invalid identifier
The BINFILE or XMLDOC identifier is not valid.
ED1 I did notice all along during testing that it was giving 1 or 2 as a list result, but my problem was getting the list in a INFO or @text().
I think the key of my problem is the file structure itself maybe.
I mess with it some today with the new info you guys gave me, maybe now I will figure it out hopefully.
maybe I'm cursed
Thank you all 3 very much
|
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Mon Jan 07, 2008 9:14 pm Post subject: |
|
|
What I would like to do is at least get the below "hintTime" value:
<cfg>
<settings hintTime>
Well I tried some more below:
| Code: | rem XMLDOC LOADFILE,1,C:\ZZZ\test_cfg[1].xml
rem %%list_values = @XMLDOC(1,VALUES,/cfg/levelList/level,"@icons")
INIFILE OPEN,C:\ZZZ\test_cfg[1].xml, XML
%%list_values = @INIREAD(cfg,)
%%list_values = @INIREAD(settings,hintTime)
INIFILE CLOSE
# levelList
# points
# settings
# settings hintTime
# download
%L = @new(list)
list add,%L,%%list_values
info @text(%L) |
This time (ABOVE example) I didnt get an error, but the INFO result was blank
=======================================
Below I tried this and got runtime error again:
| Code: | DIRECTORY CHANGE,C:\zzz
XMLDOC LOADFILE,1,test.xml
%%hintTime = @XMLDOC(VALUES,1,cfg,settings,"@hintTime")
Info %%hintTime@CR() |
RUNTIME ERROR LINE 2
43
Invalid identifier
The BINFILE or XMLDOC identifier is not valid.
Below is file "test.xml" shortened internally for easier testing:
<cfg>
<settings col ='8' match = '3' tileSize = '50' hintTime = '6000' />
</cfg>
Itendifier ERROR was what I kept getting yesterday - I'll keep trying...
| Description: |
| Heres the xml-cfg file zipped.. |
|
 Download |
| Filename: |
test_cfg[1].zip |
| Filesize: |
669 Bytes |
| Downloaded: |
1461 Time(s) |
|
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Mon Jan 07, 2008 10:34 pm Post subject: |
|
|
Years ago, I had a huge XML parsing routine coded. I used it for a RSS reader, and then again for a Weather Report app. It didn't matter how deep the levels went with this either. But! I lost it in an HD crash along with my weather report program and the RSS reader I made with the code. It was a daunting task and I have never tried to recreate it again.
Suffice it to say though, that even without the new XML facilities in VDS, VDS is still more than capable of dealing with XML if you're willing to do the research and spend the time coding it.
_________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Mon Jan 07, 2008 11:36 pm Post subject: |
|
|
Try using XMLDOC CREATE instead of LIST CREATE and Use XMLDOC CLOSE instead of LIST CLOSE.
I edited Dragonshere's code below:
| Code: | XMLDOC CREATE,1
XMLDOC LOADFILE,1,C:\ZZZ\test_cfg[1].xml
%%Icons = @XMLDOC(VALUES,1,/cfg/levelList/level,"@icons")
Info %%Icons@CR()
XMLDOC CLOSE,1 |
Note: This will only give you the first instance of /cfg/levelList/level,"@icons
-OR-
| vtol wrote: | | What I would like to do is at least get the below "hintTime" value: |
| Code: | XMLDOC CREATE,1
XMLDOC LOADFILE,1,C:\ZZZ\test_cfg[1].xml
%%hintTime = @XMLDOC(VALUES,1,/cfg/settings,"@hintTime")
Info %%hintTime@CR()
XMLDOC CLOSE,1 |
This might work too since you only have one instance:
%%hintTime = @XMLDOC(VALUE,1,/cfg/settings"@hintTime")
Note: I haven't tested this and the helpfile doesn't mention getting attributes when using the VALUE param.
Question: In you app are you creating the XML file or are you getting it from somewhere else. If you are creating it, you might consider formating it differently by making all those 'Attributes' into 'Values' instead. Unfortunately, from looking at the XML file I get the impression that it's a config file from a game, meaning reformating is probably not an option.
Last edited by Aslan on Tue Jan 08, 2008 6:11 am; edited 2 times in total |
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Tue Jan 08, 2008 5:35 am Post subject: |
|
|
I thought the VALUES and ID are suposed to be switched around, and is the ID number the same as LIST number?
Its just a first thing (from a game) I could find to start testing the new VDS6 XML fearures, once I had trouble I couldnt quit messing with it, heehee.
I still get them same ERRORs.
QUESTION:
Will the VDS6 XML READ values look the same as when viewing the file in notepad, or will I see extra code or embeded charactors etc..
I might mess with it tommorrow some more.
|
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Tue Jan 08, 2008 5:57 am Post subject: |
|
|
| vtol wrote: | | I thought the VALUES and ID are suposed to be switched around, and is the ID number the same as LIST number? |
You are correct. Yes. Sorry about that. I was also wrong about removing "cfg" from the path. I corrected it in my earlier post
| vtol wrote: | QUESTION:
Will the VDS6 XML READ values look the same as when viewing the file in notepad, or will I see extra code or embeded charactors etc.. |
Neither... See for your self:
(This has been tested)
| Code: | XMLDOC CREATE,1
XMLDOC LOADFILE,1,C:\ZZZ\test_cfg[1].xml
%%hintTime = @XMLDOC(VALUES,1,/cfg/settings,"@hintTime")
Info %%hintTime
XMLDOC CLOSE,1
exit |
For the above to work the "settings" line in your XML file needs to be written like this:
| Code: | | <settings col="8" row="8" match="3" burstTime="12" timerFrequency="33" tileSize="50" hintTime="6000"/> |
Note that there is no space between attribute names, (=) and the value.
Also the value has to be in "quotes".
|
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Tue Jan 08, 2008 10:58 pm Post subject: |
|
|
Cool
You solve my great mystery and others tiny mystery
So what I see in notpad is all there is too see, I see.
Here I did not have to deal the the spaces, it seems the quotes were the only thing needed corrected.
Thanks very much Asian, now I can stop banging my head on it
So I'm guessing the reason the .xml cfg file is written that is so Action Script or C can use it also.
I noticed the SWF game file when decompiled uses C and action script and what ever else.
I would like to be able to lower the music volume for my old mum, but that game looks to technical to waste time on.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|