I've recently played a little with MSXML interfaces and created a mini class to read and create base xml files for program settings.
There is only one class which can represent a root xml document, or xml node. It uses unicode strings because MSXML is implemented in wide character set.
A small example - enumerating all nodes:sub main()
{
XML doc;
if (doc.Open(L"xml_read.xml"))
{
EnumChilds(doc, 0);
}
}
sub EnumChilds(XML parent, int indent)
{
XML node;
if (parent.GetFirstNode(&node))
{
do {
printf("%s%S", strspace(indent), node.GetName());
if (!wcscmp(node.GetName(), L"#text"))
{
printf(" = %S", node.GetText());
}
print();
EnumChilds(node, indent + 3);
}
until !parent.GetNextNode(&node);
}
}
Attached examples for reading and creating, both for Aurora and Emergence.
I have extended the class with cdata and comment nodes. The Open method has now optional parameters to a/synchronously load and to load/ignore external dependencies.
Added example with tiny RSS reader. The xml file is downloaded from ionicwind.com, and finally the html code is generated and displayed in webbrowser window.
EDIT: fixed missing SysFreeString in Cleanup method.
(http://i38.tinypic.com/1znwqw1.png)
Next example shows how to download the xml file asynchronously. I've added a function which removes potential dangerous elements from topics (script, iframe, object, embed) and ensures that every topic has closed all html tags.
For tag closing there is a hidden html document created by CoCreateInstance. By setting the body.innerHTML to topic text, and returning the text back we can close all opened tags, but before retrieving it back, we do a cleanup loop for document.body.all.
Added blue border for code and quote.
Todo's: only topic content is filtered. All other strings returned by XML::GetText() should be also filtered. To close tags and apply security filter to html code you can use CloseAllTags() function. It returns a BSTR with unicode string.
You can also run it with a parameter:xml_rss_async.exe http://a.b.c/rss.xml
EDIT: added StripTags function.