I recommend MSXML. It may look complicated, but it's nice and easy when you get used to it.
Here's a sample:
input.xml:
FL
FR
RL
RR
code:
#include
#include
#include
#import rename_namespace(_T("MSXML"))
int main(int argc, char* argv[]) {
HRESULT hr = CoInitialize(NULL);
if (SUCCEEDED(hr)) {
try {
MSXML::IXMLDOMDocument2Ptr xmlDoc;
hr = xmlDoc.CreateInstance(__uuidof(MSXML::DOMDocument60),
NULL, CLSCTX_INPROC_SERVER);
// TODO: if (FAILED(hr))...
if (xmlDoc->load(_T("input.xml")) != VARIANT_TRUE) {
printf("Unable to load input.xml\n");
} else {
printf("XML was successfully loaded\n");
xmlDoc->setProperty("SelectionLanguage", "XPath");
MSXML::IXMLDOMNodeListPtr wheels = xmlDoc->selectNodes("/Car/Wheels/*");
printf("Car has %u wheels\n", wheels->Getlength());
MSXML::IXMLDOMNodePtr node;
node = xmlDoc->createNode(MSXML::NODE_ELEMENT, _T("Engine"), _T(""));
node->text = _T("Engine 1.0");
xmlDoc->documentElement->appendChild(node);
hr = xmlDoc->save(_T("output.xml"));
if (SUCCEEDED(hr))
printf("output.xml successfully saved\n");
}
} catch (_com_error &e) {
printf("ERROR: %ws\n", e.ErrorMessage());
}
CoUninitialize();
}
return 0;
}
output:
XML was successfully loaded
Car has 4 wheels
output.xml successfully saved
output.xml:
1
2
3
4
Engine 1.0
You will find everything you need here:
http://msdn.microsoft.com/en-us/library/ms765540(v=vs.85).aspx
Hope someone finds this useful ;)