• 4744阅读
  • 0回复

QT的xml dom是否支持xpath那样的解析? [复制链接]

上一主题 下一主题
离线newhappy
 
只看楼主 倒序阅读 楼主  发表于: 2006-08-09
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
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重新编辑 ]
快速回复
限100 字节
 
上一个 下一个