第二次尝试。
所以使用
>>> for node in tree.iter():
... print(node.tag)
...
我得到以下。
{http://www.smpte-ra.org/schemas/430-3/2006/ETM}DCinemaSecurityMessage
{http://www.smpte-ra.org/schemas/430-3/2006/ETM}AuthenticatedPublic
{http://www.smpte-ra.org/schemas/430-3/2006/ETM}MessageId
{http://www.smpte-ra.org/schemas/430-3/2006/ETM}MessageType
{http://www.smpte-ra.org/schemas/430-3/2006/ETM}AnnotationText
{http://www.smpte-ra.org/schemas/430-3/2006/ETM}IssueDate
{http://www.smpte-ra.org/schemas/430-3/2006/ETM}Signer
{http://www.w3.org/2000/09/xmldsig#}X509IssuerName
{http://www.w3.org/2000/09/xmldsig#}X509SerialNumber
{http://www.smpte-ra.org/schemas/430-3/2006/ETM}RequiredExtensions
{http://www.smpte-ra.org/schemas/430-1/2006/KDM}KDMRequiredExtensions
{http://www.smpte-ra.org/schemas/430-1/2006/KDM}Recipient
{http://www.smpte-ra.org/schemas/430-1/2006/KDM}X509IssuerSerial
{http://www.w3.org/2000/09/xmldsig#}X509IssuerName
{http://www.w3.org/2000/09/xmldsig#}X509SerialNumber
{http://www.smpte-ra.org/schemas/430-1/2006/KDM}X509SubjectName
{http://www.smpte-ra.org/schemas/430-1/2006/KDM}CompositionPlaylistId
{http://www.smpte-ra.org/schemas/430-1/2006/KDM}ContentTitleText
{http://www.smpte-ra.org/schemas/430-1/2006/KDM}ContentKeysNotValidBefore
{http://www.smpte-ra.org/schemas/430-1/2006/KDM}ContentKeysNotValidAfter
{http://www.smpte-ra.org/schemas/430-1/2006/KDM}AuthorizedDeviceInfo
{http://www.smpte-ra.org/schemas/430-1/2006/KDM}DeviceListIdentifier
{http://www.smpte-ra.org/schemas/430-1/2006/KDM}DeviceList
{http://www.smpte-ra.org/schemas/430-1/2006/KDM}CertificateThumbprint
在第一行中,如何查看 DCinemaSecurityMessage 之后的文本?或者遵循 { http://www.smpte-ra.org/schemas/430-1/2006/KDM } 的任何其他测试?
我正在查看的实际 xml 的一部分是:
我不清楚我如何遍历和存储该信息的某些部分。我是否必须知道某个东西是子节点还是节点,或者我是否可以正确地使用一个 for 循环来查找标识符,然后将它找到的内容存储在标识符之后?
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><DCinemaSecurityMessage xmlns="http://www.smpte-ra.org/schemas/430-3/2006/ETM" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:enc="http://www.w3.org/2001/04/xmlenc#">
<!-- Generated by Waimea 0.4.28l (wlib 0.9.53) -->
<AuthenticatedPublic Id="ID_AuthenticatedPublic">
<MessageId>urn:uuid:0bb31789-de90-4e17-859b-dc771ff97280</MessageId>
<MessageType>http://www.smpte-ra.org/430-1/2006/KDM#kdm-key-type</MessageType>
<AnnotationText>CLOUDATLAS_FTR-1_S_EN-EN_51_PRE_2K_20120830_ADC_OV ~ KDM for SM.Dolby256-DSP100-000004d8</AnnotationText>
<IssueDate>2012-09-28T17:39:53+00:00</IssueDate>
<Signer>
<dsig:X509IssuerName>dnQualifier=G4c6KCUZh7AzcyJnMCXbf9GAfAA=,CN=.cc-wm-2336-000020,OU=.cc-ra-1a.s430-2.ca.cinecert.com,O=.ca.cinecert.com</dsig:X509IssuerName>
<dsig:X509SerialNumber>61638</dsig:X509SerialNumber>
</Signer>