PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

XML Parsing

Hello,
I use XML WebServices in my application to retrieve data. I need to read this XML. My XML looks like :

Code:

<BLS_ASR>
<SearchId>716560b4-4921-4fc1-a036-04c9163f913a</SearchId>
<S>
<SRA>3</SRA>
<SRC>105</SRC>
</S>
</BLS_ASR>


I have try to use the xmlrpc sample to anderstand how to use EXmlRpcNode and ClassEXmlRpc but when i wrote :
node = xmlrpc.GetRoot()["BLS_ASR"];
node is on error.
What should I write to read my XML with this clases ?
Should I need to use a ClassEXml and EXml_Callback to read my xml ?
Thank you

Regards
David
I think this thread belongs in the Edge forum, so I'm moving it.

Dan East
Hi David,

The XML RPC parser is for a specific XML structure, it doesn't seem your example follows this structure. We recommend using the basic XML parser in combination with the EXml_Callback function.
Ok thanks,

i'm punish :wink:

regards
David
Hi Edge,

I'm having some trouble trying to get the xml parser working. Here's what I'm trying to do:

Code:

ClassEXml myXML;
const char* xmlString = "<parent name='parent'><child name='child'>Test value</child></parent>";
myXML.Open(xmlString);
myXML.Parse();
EXmlNode node = myXML.GetRoot();
shared->main->Log(node.GetName());


When I run this, the log file shows "root" instead of "parent" as I would've expected. Do I need to generate the root node through the parse function's callback? If so, could you please explain how to do this? I see the callback example in the docs, but I don't see how I can use it to create my root node.

Thanks,
John
Hi,

If you're using XMLNodes, you don't need the callback function. These are two different approaches (which can be used at the same time), pick the one that suits your needs.

To get the name of the parent node, you can use the following example:

Code:

node["parent"].GetName();
Thanks Edge. It's working well now on my PC build using nodes, but it's crashing in Windows Mobile when I run the following:

Code:

ClassEXml mapXML;
mapXML.Open("<parent><child>text</child></parent>");
shared->main->Log("ONE");
mapXML.Parse();
shared->main->Log("TWO");
EXmlNode node = mapXML.GetRoot()[0];
...


When I run the code above on my phone or device emulator, the log file shows "ONE" but not "TWO", so it seems the problem is occurring in Parse(). Is there a problem with my data setup? Or with Parse() in Windows Mobile?
Hi,

Does it also crash when removing this line of code?

Code:

EXmlNode node = mapXML.GetRoot()[0];



Also, please use the following code instead to access nodes (notice the & sign before the node variable):

Code:

EXmlNode &node; = mapXML.GetRoot()[0];
Hi,

I removed the last line and dropped the code into the HelloWorld sample, and it's still crashing as soon as it hits Parse(). Thanks again for the help!
Hi,

We've found the bug, a fix will be available in the next EDGELIB release to be released real soon.
Great, thanks!