Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am trying parse the xml file but im not getting the all the result
could you please help me here.

What I have tried:

?xml version="1.0"?><bases count='5'><base><attr name='username' value=ven'/><attr name='ip' value=ram'/></base><base><attr name='username' value=ven'/><atr name='ip' value=ram'/></base><base><attr name='username' value=ven'/><atr name='ip' value=ram'/></base></bases>


C++
TElem eroot(iRootElm); // eroot contain the above xml file 
wstring count = eroot.attr(L"count");//count coiming correctly
TElem elementnode = eroot.subnode(L"base");
for (TElem e = elementnode.begin(); (elementnode.elem && (elementnode != eroot.end())); elementnode++)
{      
TElem elementnsubode = e;     //updated now      
    wstring csName = elementnsubode.attr(L"name");//
    wstring csValue = elementnsubode.attr(L"value");
}

the above is returning only username and ven
its nor printing the below

<pre><atr name='uname2' value=ram'/></base></bases>this
Posted
Updated 27-Jun-18 0:03am
v5
Comments
Richard MacCutchan 27-Jun-18 5:31am    
Which parser library are you using?
Member 13089825 27-Jun-18 5:35am    
com parser
CComPtr<ixmldomdocument> iXMLDoc;
iXMLDoc.CoCreateInstance(__uuidof(DOMDocument));
VARIANT_BOOL bSuccess = false;
CComPtr<ixmldomelement> iRootElm;
iXMLDoc->loadXML((bsResponse), &bSuccess);
Richard MacCutchan 27-Jun-18 5:36am    
The second element is spelled "atr" not "attr".
Member 13089825 27-Jun-18 5:39am    
modified(it typoo error) but still same issue
Richard MacCutchan 27-Jun-18 5:45am    
I don't see anywhere in your code where you initialise the elementsubnode object. And I cannot see what that loop is actually supposed to do.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900