Discuz! Board

 

 

Search
Discuz! Board Forum Integration Questions Reading Plist/Xml Files
View: 2214|Reply: 21
go

Reading Plist/Xml Files

Rank: 4

Post on 2011-6-14 16:05 |All posts
Hey,

Are there any default methods in Papaya to read/write and edit plists or Xml files?

Rank: 4

Post on 2011-6-14 16:11 |All posts
Yes, there is XML api
Refer to API_reference.pdf in docs.
And there is a sample project called spritesheet_xml

Rank: 4

Post on 2011-6-14 17:04 |All posts
Awesome!! thanks...

Rank: 4

Post on 2011-6-14 19:07 |All posts
Another issue:

Code:
var dict = parsexml("xmlfile.xml",1);
trace(dict);
trace(dict.keys());

Xml File:
<begin>

         <inner>

                <a>1</a>

                <b>2</b>

        </inner>

</begin>

When I run the code dict.keys() gives only "begin" as the key (refer to the attached output). Shouldn't it be shwoing all the keys ["begin","inner","a","b"]  ?? How can we get the values of a and b directly?
Attachment: You need to Login to download attachments. No account? Register

Rank: 4

Post on 2011-6-15 10:07 |All posts
This is correct output. dict is at the first level. There is only one 1st level key 'begin'.

dict.get("begin").get("#children")[0].keys()  will return ["inner"]

You need to know the hierarchy and use multiple get() to traverse.

Rank: 4

Post on 2011-6-15 13:50 |All posts
Ok thanks it works ..
But I think you should include an example in the docs too because it is not that straight forward to understand for someone new to Papaya

Rank: 4

Post on 2011-6-15 14:09 |All posts
One more thing .. Is there any default method to edit the xml file?

Rank: 4

Post on 2011-6-16 14:38 |All posts
Any ideas ???

Rank: 4

Post on 2011-6-16 14:54 |All posts
Default method? Not sure what do you mean. You can write a file with xml in it. Edit it with and file editor.

Rank: 4

Post on 2011-6-16 15:33 |All posts
You mean that I cannot edit the same xml file that I read from the 'res' folder?
Security Q&A Change Security code Change

Archiver|Comsenz Inc.

All time is GMT+8, 2013-5-24 13:55 , Processed in 0.034005 second(s), 11 queries .

Powered by Discuz! X1.5

© 2001-2010 Comsenz Inc.