xml parsing in adobe alchemy
hello can you prvide an example how to parse xml file in adobe alchemy. im trying to work on expat, however i got no luck on passing of bytearrays t开发者_StackOverflowo and from the c code.
do i need to pass the byte array of file to the alchemy, or is it enough to pass the filename.
thanks.
cbs
If you want to parse xml within Alchemy, you'll need to use a C/C++ parsing library.
As for getting the xml into Alchemy:
- The simplest way would be to simply pass the xml string into the function and Alchemy will marshal it for you.
- Alternatively you could use supplyFile/fopen to open a "virtual file" that maps to a ByteArray.
- You could also copy the ByteArray straight into Alchemy's RAM.
Here is a comparison of methods to move ByteArrays into Alchemy.
Here is how I passed an embedded file:
[Embed(source="Test.txt", mimeType="application/octet-stream")] public var TestClass:Class;
private function echo():String { var loader:CLibInit=new CLibInit; var lib:Object = loader.init() var data:Object = new TestClass(); lib.test(data.length, data); }
The C code is:
static AS3_Val test(void *self, AS3_Val args) { int length; AS3_Val data=AS3_Undefined(); AS3_ArrayValue(args, "IntType, AS3ValType", &length, &data)
unsigned char buffer[length]; AS3_ByteArray_seek(buffer, 0, SEEK_SET); }
精彩评论