xmlTextReaderPreservePattern

xmlTextReaderPreservePattern

正在尝试使用“xmlTextReaderPreservePattern”。
当xpath中有名称空间限定符时,它不起作用。我有段错误。
我确实需要在同一个xml中使用多个名称空间。
有什么想法吗?

const char *pattern = "/wrapper:TestMessage/wrapper:Header/head:Frame/head:Id/head:StoreId/head:SysId/head:UserId"; // does not give seg fault
//const char *pattern = "/TestMessage/Header/Frame/Id/StoreId/SysId/UserId"; //does give seg fault
const char *namespace = "xmlns='urn:wrapper' xmlns:head='urn:std:header:tech:xsd:headeVersion.001.001.01' xmlns:message='urn:std:message:tech:xsd:messageVersion.001.001.01' "; // ddoes not give seg fault
//const char *pattern = "test"; // does not give seg fault
//const char *namespace = "test"; // does not give seg fault

if (xmlTextReaderPreservePattern(reader, (const xmlChar *) pattern, (const xmlChar **) &namespace) < 0) {
    fprintf(stderr, "%s : failed add preserve pattern %s\n",   XMLFileName, (const char *) pattern);
}

最佳答案

这行得通

const char *namespace[] = {"urn:wrapper", "wrapper", "urn:std:header:tech:xsd:headeVersion.001.001.01", "head", "urn:std:message:tech:xsd:messageVersion.001.001.01", "message"};

例如,不能工作的是xpath和text()之类的函数。
onst char *pattern = "/wrapper:TestMessage/wrapper:Header/head:Frame/head:Id/head:StoreId/head:SysId/head:UserId/text()";

关于c - libxml2-xmlTextReaderPreservePattern-centos5-libxml2-2.9.1-gcc,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24629624/

10-11 02:44