0

我已经阅读了Bada 中关于XML 解析的教程。但我不想使用文件。我需要从 Osp::Base::String 解析我的 XML。任何想法我应该使用哪些方法?到目前为止,我已经更换

xpathCtx = xmlXPathNewContext(doc);
if(xpathCtx == NULL) {
   AppLog("Error: unable to create new XPath context");
   xmlFreeDoc(doc);
   return(E_IO);
}

xpathCtx = (xmlXPathContextPtr) xmlXPathNewCString("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><title lang=\"en\">XQuery Kick Start</title><title lang=\"en\">Learning XML</title>");

但是模拟器只是关闭了。

谢谢你。

4

1 回答 1

1

您的代码是错误的,因为您不能从 xmlXPathObjectPtr 转换为 xmlXPathContextPtr:它们是不同的结构。

教程中给出的代码是正确的,只需使用

xmlDocPtr xmlReadDoc (const xmlChar * cur, const char * URL, const char * encoding, int options)

代替

xmlReadFile(..)

要了解如何使用此功能,请查看文档和 libXML2 网站上的示例。

于 2010-07-20T21:26:15.713 回答