Archived Forum Post

Index of archived forum posts

Question:

How to get my data from xml

Apr 28 '17 at 10:52

Hello, I am having hard time to understand correctly how to get a special position inside xml.

My xml looks like this:

<root>
    <searchRoot>
        <fruit color="red">apple</fruit>
        <fruit color="green">pear</fruit>
        <veg color="orange">carrot</veg>
        <meat animal="cow">beef</meat>
        <xyz>
            <fruit color="blue">blueberry</fruit>
            <veg color="green">broccoli</veg>
        </xyz>
        <fruit color="purple">grape</fruit>
        <cheese color="yellow">cheddar</cheese>
    </searchRoot>
    <Haus>
        <door color="white">white doors</door>
        <order orderid="12345">the order id</order>

    </Haus>
    <fruit color="red">strawberry</fruit>
    <fruit color="orange">peach</fruit>
</root>

I want to design a function I can pass to what I am searching for. In this case I search for the attribute orderid under <door> which is inside <haus>.

I was not able to get it to work. I used:

node = xml.FindChild("Haus");
node =  xml.SearchForTag(0,"door");

CkString value;
value = xml.getAttrValue("orderid");