<root>
<user id="111" name ="abc">
hello world;
</user>
</root>
只要能把 id="111" 和name ="abc">抓出来也ok的
[/Quote]
上面那段不是写着的啊,
You can loop through beginning at n=0 and incrementing n until it returns an empty string to discover all of the attributes an element has.
通过自增属性位置遍历属性表啊。
for(int n = 0 ;;n++)
{
xml.GetAttribName(n);
//如果是空字符串,就表示遍历完了啊。否则就做你要做的处理啊。
}
CMarkup GetAttribName Method
MCD_STR GetAttribName( int n ) const;Call GetAttribName to get the attribute name of the zero-based nth attribute of the main position element. If there is no current position, it returns an empty string regardless of n. If the child position element has no nth attribute, it returns an empty string. This is used to query the attributes that an element has. You can loop through beginning at n=0 and incrementing n until it returns an empty string to discover all of the attributes an element has.
Here is an example of getting the first attribute of this small sample document:
<ROOT customcode="35"/>xml.ResetPos();
xml.FindElem();
str sAttribName = xml.GetAttribName( 0 ); // "customcode"
str sValue = xml.GetAttrib(sAttribName); // "35"SetAttrib also works when the main position is a processing instruction node. See Node Methods in CMarkup.