Help!!! How to read local xml files?

I use XMLHttpRequest to read local xml file in cocos2d-html5.But it can not read by the same way in cocos2d-x JSB.How to read local xml files in cocos2d-x JSB

There’re no xml parser in cocos2d-x JSB right now. I advise you use JSON format instead.

James Chen wrote:

There’re no xml parser in cocos2d-x JSB right now. I advise you use JSON format instead.

Can I use plist format?

http://www.cocos2d-x.org/boards/20/topics/28538

James Chen wrote:

http://www.cocos2d-x.org/boards/20/topics/28538

Which format can parser in cocos2d-x JSB right now,And how to parser them? I perfer to use cocos2d-x JSB api rather than I bind it by myself.

Javascript supports JSON.parse() originally.

James Chen wrote:

Javascript supports JSON.parse() originally.

Thanks a lot

James Chen wrote:

Javascript supports JSON.parse() originally.

By the way,How to read file content that supported both in cocos2d-HTML5 and cocos2d-x JSB?

cc.FileUtils.getInstance().getStringFromFile(filename);

James Chen wrote:

cc.FileUtils.getInstance().getStringFromFile(filename);

Is it need to call other method before call this method?I call this method but get void by return.

Not needs other method.

James Chen wrote:

Not needs other method.

Why I get void by return?I try to read some ccbi file which can read by cc.BuilderReader.load.But it still get void by return.

Platform? Engine version?
Please, please don’t just say the problem, please provide the details.

Platform? Engine version?
Please, please don’t just say the problem, please provide the details.

James Chen wrote:

Platform? Engine version?
Please, please don’t just say the problem, please provide the details.

Sorry.Plaform is cocos2d-HTML5 2.1.4

:frowning: , so you don’t use cocos2d-x JSB?
If so please post your feedback here(http://www.cocos2d-x.org/projects/cocos2d-x/boards/19)
This sub forum is just for cocos2d-x JSB.

James Chen wrote:

:frowning: , so you don’t use cocos2d-x JSB?
If so please post your feedback here(http://www.cocos2d-x.org/projects/cocos2d-x/boards/19)
This sub forum is just for cocos2d-x JSB.

I develop in cocos2d-HTML5 and also run it in cocos2d-x JSB.So I want to know the way which can supported both in HTML5 and JSB

OK. I noticed that you read .ccbi format from file. .ccbi is binary format. So getStringFromFile will not work.
Instead, you could use cc.FileUtils.getInstance.getByteArrayFromFile;.

James Chen wrote:

OK. I noticed that you read .ccbi format from file. .ccbi is binary format. So getStringFromFile will not work.
Instead, you could use cc.FileUtils.getInstance.getByteArrayFromFile;.

Actually,I just want to read json file both in cocos2d-x JSB and cocos2d-HTML5

iOS, Android?
Could you provide a demo to reproduce it. Otherwise, I have no ideas about that.