<已解决>lr_xml_find 查询 ValueParam 的问题
本帖最后由 3396408 于 2012-3-28 16:29 编辑int find_cnt;
char *xml_input =
"<acme_org>"
"<employee level=\"manager\">John Smith"
"<cubicle>227</cubicle>"
"</employee>"
"</acme_org>";
find_cnt = lr_xml_find("XML={XML_Input_Param}",
"ValueParam=cubicle",
"Query=/acme_org/employee",
LAST );
这样无法查询出“cubicle”这个属性,看了帮助文档,貌似应该是可以查询出这个属性值是否存在的,上述代码具体要怎么修改才可以呢?
char * xml_input =
"<acme_org>"
" <accounts_dept>"
"<employee>"
" <name>John Smith</name>"
"<cubicle>227</cubicle>"
"<extension>2145</extension>"
"</employee>"
"</accounts_dept>"
"<engineering_dept>"
"<employee>"
"<name>Sue Jones</name>"
"<extension>2375</extension>"
"</employee>"
"</engineering_dept>"
"</acme_org>";
int find_cnt;
lr_message(xml_input);
lr_save_string(xml_input,"xml");
lr_message(lr_eval_string("{xml}"));
lr_save_string("2145","Xx_1");
lr_save_string("2375","Xx_2");
find_cnt = lr_xml_find("XML={xml}",
"ValueParam=Xx", /*查找多个参数是否存在是用到的,注意参数没有{}*/
"SelectAll=yes",
"Query=//extension",
LAST );
lr_message("lr_xml_find成功次数:%d",find_cnt); find_cnt = lr_xml_find("XML={XML_Input_Param}",
"Value=227",
"Query=/acme_org/employee/cubicle",
LAST); 补充说,不是要查询227是否存在,这个可以搞定
是要查询cubicle是否存在 等待高人指点 lr_xml_find做不到你想要的效果,不过可以用lr_xml_extract实现 int find_cnt;
char *xml_input =
"<acme_org>"
"<employee level=\"manager\">John Smith"
"<cubicle>227</cubicle>"
"</employee>"
"</acme_org>";
lr_save_string(xml_input,"XML_Input_Param");
find_cnt=lr_xml_extract("XML={XML_Input_Param}",
"XMLFragmentParam=Result",
"Query=/acme_org/employee/cubicle",
"NotFound=Continue",
LAST );
if(find_cnt>0){
lr_output_message("Found!");
}else{
lr_output_message("Not Found!");
} lr_xml_extract用法搞明白了,多谢!
请教lr_xml_find 的"ValueParam"是用来查询什么呢,语法如何,能否给个简单例子说明一下? lr_xml_find用来查询John Smith、227、manager这样的属性值,具体使用方法看LR帮助
页:
[1]