首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

selectSingleNode使用有关问题

2012-01-31 
selectSingleNode使用问题我的c++程序里面写了如下代码pNode pDoc-selectSingleNode(/xmcda:XMCDA/per

selectSingleNode使用问题
我的c++程序里面写了如下代码

pNode = pDoc->selectSingleNode("/xmcda:XMCDA/performanceTable/alternativePerformances[alternativeID='a00']) ;
 
没有问题,但是alternativeID以一个变量来判断时,即

 string str="a00";

pNode = pDoc->selectSingleNode("/xmcda:XMCDA/performanceTable/alternativePerformances[alternativeID=strValue]) ;
就找不到对应的节点了

如何在xpath里面使用变量阿?
谢谢!

[解决办法]
其实我有点点怀疑你的代码能不能编译过去:)

你可以先把str的值写到XPath字符串中

CString strValue("a00");

String strXPath("/xmcda:XMCDA/performanceTable/alternativePerformances[@alternativeID=\'");
strXPath += strValue;
strXPath += '\'' // 这时候strXPath的内容就是/xx/xx/[@xx='xx']这样的形式了


[解决办法]
_bstr_t 是封装BTSR的类

构造函数:
_bstr_t(
const char* s2 
);

_bstr_t str("tryText");

热点排行