ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > irrXML
forum topic indicator Simple XML
person icon
anpoit00
Registered User
Quote
2013-10-30 18:40:43

I have the following problem, I want to read xml file but have no idea how the code should look like.


<?xml version="1.0" standalone="yes"?>
<Mabi_x0020_config>
<Axis>
<name>x</name>
<output_number>1</output_number>
</Axis>
<Axis>
<name>y</name>
<output_number>2</output_number>
</Axis>
</Mabi_x0020_config>




From the example I'll I could not do this.

Does anyone have a suggestion?

person icon
niko
Moderator
Quote
2013-10-31 07:45:56

But the example code shows nearly exactly how to do that. What is your problem exactly?

person icon
anpoit00
Registered User
Quote
2013-10-31 10:16:24

Hallo Nico,



while(xml && xml->read())
{
switch(xml->getNodeType())
{
case EXN_TEXT:
// in this xml file, the only text which occurs is the messageText
if (!strcmp("name", xml->getNodeName()))
messageText = xml->getNodeData();
case EXN_ELEMENT:
{
if (!strcmp("Axis", xml->getNodeName()))
{
a_param = new Axis_Parameter();
}
if (!strcmp("name", xml->getNodeName()))
//messageText = xml->getNodeData(); hier would i like to receive ´x´
break;
}
case EXN_ELEMENT_END:
{
if (!strcmp("Axis", xml->getNodeName()))
list_axis.push_back(*a_param);
break;
}

//break;
}
}

// delete the xml parser after usage
delete xml;




person icon
niko
Moderator
Quote
2013-10-31 14:23:59

x is in an element inside of 'axis'. So you would get the content of 'x' in the case of EXN_TEXT above. You could store a bool somewhere which you set to true if you are inside an element with the tag 'name' and which you set to false on ELEMENT_END, so then you can ckeck in the EXN_TEXT if this is true and get the x.

person icon
anpoit00
Registered User
Quote
2013-10-31 18:07:04

Thanks Nico.


Create reply:










 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |