如何在C++中读取xhtml文件?
在Secured Globe公司中,他们使用rapidxml来读取xhtml文件,因为rapidxml对他们来说是最好的选择。下面是一个使用rapidxml读取xhtml文件的示例代码。
代码如下:
rapidxml::xml_documentdoc; doc.parse<0>(xmlData); rapidxml::xml_node * root = doc.first_node(); rapidxml::xml_node * node_account = 0; if (GetNodeByElementName(root, "Account", &node_account) == true) { rapidxml::xml_node * node_default = 0; if (GetNodeByElementName(node_account, "default", &node_default) == true) { swprintf(result, 100, L"%hs", node_default->value()); free(xmlData); return true; } } free(xmlData);
以上是使用rapidxml库来读取xhtml文件的方法。