- 论坛徽章:
- 0
|
20可用积分
我想用sax包来解析xml, 要求如下:
[code=Python]
<?xml version="1.0" encoding="UTF-8"?>
<waf>
<policy> acl </policy>
<prot>
<dstip>2.2.2.2</dstip>
<dstip>3.3.3.3</dstip>
<dstport>80</dstport>
<srcip>3.3.3.3</srcip>
<srcport>8888</srcport>
<protocol>17</protocol>
</prot>
<other haha="google.com" test_case_id="1" >
<action>0</action>
<dstip>33333333</dstip>
<res>0</res>
<res a="b" b="2" >0</res>
<res a="c" b="3" c="4" >88</res>
<res a="b" b="2" >0</res>
</other>
<other heihei="google.com" test_case_id2="2" >
<res a="b" b="2" >0</res>
</other>
<other heihei3="baidu.com" test_case_id3="3" >
<res a="c" b="3">88</res>
<dd gg = "pengwei" >wpw</dd>
</other>
<m>
<w>
<dd gg = "dongmei" >wpw</dd>
</w>
</m>
<rule ID="18612269" value="\x22" />
</waf>
[/code]
需求:
1, 返回某个特定标签下的所有attr 如ther标签有多个,我只想返回第二个other标签下的所有标签
2, 取出某个特定标签下的某个子标签的标签属性和标签值,如:取出第一个other标签下的第三个res的attr属性和标签值
请指教 多谢~ |
|