Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 在Bada中使用XPath从字符串解析XML?_String_File_Parsing_Xpath_Bada - Fatal编程技术网

String 在Bada中使用XPath从字符串解析XML?

String 在Bada中使用XPath从字符串解析XML?,string,file,parsing,xpath,bada,String,File,Parsing,Xpath,Bada,我已经阅读了关于巴达的教程。但我不想使用文件。我需要从Osp::Base::String解析XML。我该用什么方法?到目前为止,我已经取代了 xpathCtx = xmlXPathNewContext(doc); if(xpathCtx == NULL) { AppLog("Error: unable to create new XPath context"); xmlFreeDoc(doc); return(E_IO); } 与 xpathCtx=(xmlXPathCont

我已经阅读了关于巴达的教程。但我不想使用文件。我需要从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(“XQuery XML”);
但仿真器只是关闭了


谢谢。

您的代码是错误的,因为您无法从xmlXPathObjectPtr强制转换为xmlXPathContextPtr:它们是不同的结构

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

xmlDocPtr xmlReadDoc(const xmlChar*cur,
常量字符*URL,
常量字符*编码,
整数选项)

而不是

xmlReadFile(..)


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

我的朋友,你说得对。我只希望在我自己解决问题之前,你已经正确地回答了我的问题。讽刺的是,我现在不是从字符串解析XML,而是从文件解析XML,就像在教程中一样。我希望这不会大大降低我的应用程序性能。
xpathCtx = (xmlXPathContextPtr) xmlXPathNewCString("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><title lang=\"en\">XQuery Kick Start</title><title lang=\"en\">Learning XML</title>");