elementsByTagName
函数是否支持xxx/bbb/ccc....这样的xpath解析规则?
似乎老出错!没有获得我想要的fuck字符窜!
xml src:
<?xml version="1.0" ?>
<root>
<children code="0">
<child code="0">child0</child>
<child code="1">child1</child>
</children>
<children code="1">
<child code="3">child3</child>
<child code="4">child4</child>
</children>
<hello>
<a>fuck</a>
<b>world</b>
<c>go</c>
</hello>
</root>
str = "hello/a";
QDomElement xRoot =m_xDocPtr ->documentElement();
QDomNodeList xList = xRoot.elementsByTagName( str );
QMessageBox::information( 0, tr( "hello" ), tr( "%1" ).arg( xList.count() ) );
QMessageBox::information( 0, tr( "hello ch cnt" ), tr( "%1" ).arg( xList.at( 0 ).childNodes().count() ) );
return static_cast<QDomElement*>( &xList.at( 0 ) ) ->text();
[ 此贴被XChinux在2006-08-09 23:58重新编辑 ]