UPDATE: still not working :( I updated part of the code to reflect what I have.
This should be a fairly straightforward question for people who have used TinyXML. I am trying to use TinyXML to parse an XML document and highlight some values. I figured out how to add to the library yesterday, and I successfully uploaded the document (hey, this is the beginning).
I read the manual and I cannot figure out how to pull out individual attributes. After Googling, I did not find an example of my specific example, so maybe someone who used TinyXML might help. The XML snippet is presented below, and I started parsing it.
XML:
<EGCs xmlns="http://tempuri.org/XMLSchema.xsd"> <card type="EGC1"> <offsets> [ ... ] </offsets> </card> <card type="EGC2"> <offsets> [ ... ] </offsets> </card> </EGCs>
Download / code analysis:
TiXmlDocument doc("EGC_Cards.xml"); if(doc.LoadFile()) { TiXmlHandle hDoc(&doc); TiXmlElement* pElem; TiXmlHandle hRoot(0); pElem = hDoc.FirstChildElement().Element(); if (!pElem) return false; hRoot = TiXmlHandle(pElem); //const char *attribval = hRoot.FirstChild("card").ToElement()->Attribute("card"); pElem = hDoc.FirstChild("EGCs").Child("card", 1).ToElement(); if(pElem) { const char* tmp = pElem->GetText(); CComboBox *combo = (CComboBox*)GetDlgItem(IDC_EGC_CARD_TYPE); combo->AddString(tmp); } }
I want to pull out each type map and save it in a row to insert into the combo box. How to access this attribute element?
source share