我得到了一个XML文件:
<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>antigon</name>
<SSIDConfig>
<SSID>
<name>antigon</name>
</SSID>
</SSIDConfig>
<connectionType>ESS</connectionType>
<connectionMode>auto</connectionMode>
<MSM>
<security>
<authEncryption>
<authentication>WPA2PSK</authentication>
<encryption>AES</encryption>
<useOneX>false</useOneX>
</authEncryption>
<sharedKey>
<keyType>passPhrase</keyType>
<protected>false</protected>
<keyMaterial>THIS IS WHAT I WANNA GET</keyMaterial>
</sharedKey>
</security>
</MSM>
<MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">
<enableRandomization>false</enableRandomization>
</MacRandomization>
</WLANProfile>
我知道HTML/XML的逻辑,但我找不到如何使用Etree和python获得“这就是我想要的”,这两个版本都在上一版本中。有人能帮我吗?非常感谢
下面
输出
See the docs(和this answer)了解有关使用ElementTree处理名称空间的详细信息
下面是一个例子:
印刷品
如果要修改该值并将其保存到文件中,请尝试以下操作:
输出(Output.xml)
注意:ElementTree不能很好地处理多个默认名称空间,所以这就是为什么在输出中添加“ns1”前缀的原因
相关问题 更多 >
编程相关推荐