У меня проблемы с выяснением, почему мое второе заявление о печати ничего не печатает, ПОМОГИТЕ!
Мой первый оператор печати print (root[0][1].text)
может проанализировать файл xml и распечатать AC-1
, в то время как другой оператор печати ниже для l oop for varible in root.iter('number'):print(varible.text)
, похоже, не находит данные на всех.
Parse XML .py
filePath='/Users/userName/Desktop/xmlFile.xml'
tree = ET.parse(filePath)
root = tree.getroot()
#This print stmt prints 'AC-1'
print (root[0][1].text)
for varible in root.iter('number'):
#This print stmt doesn't print anything
print(varible.text)
xmlFile. xml
<controls:controls xmlns="http://scap.nist.gov/schema/sp800-53/2.0" xmlns:controls="http://scap.nist.gov/schema/sp800-53/feed/2.0" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" pub_date="2015-02-03T10:11:18.645-05:00" xsi:schemaLocation="http://scap.nist.gov/schema/sp800-53/feed/2.0 http://scap.nist.gov/schema/sp800-53/feed/2.0/sp800-53-feed_2.0.xsd">
<controls:control>
<family>ACCESS CONTROL</family>
<number>AC-1</number>
<title>ACCESS CONTROL POLICY AND PROCEDURES</title>
<priority>P1</priority>
<baseline-impact>LOW</baseline-impact>
<baseline-impact>MODERATE</baseline-impact>
<baseline-impact>HIGH</baseline-impact>
<statement>
<description>The organization:</description>
<statement>
<number>AC-1a.</number>
<description>Develops, documents, and disseminates to [Assignment: organization-defined personnel or roles]:
</description>
<statement>
<number>AC-1a.1.</number>
<description>An access control policy that addresses purpose, scope, roles, responsibilities, management commitment, coordination among organizational entities, and compliance; and
</description>
</statement>
<statement>
<number>AC-1a.2.</number>
<description>Procedures to facilitate the implementation of the access control policy and associated access controls; and
</description>
</statement>
</statement>
<statement>
<number>AC-1b.</number>
<description>Reviews and updates the current:</description>
<statement>
<number>AC-1b.1.</number>
<description>
Access control policy [Assignment: organization-defined frequency]; and
</description>
</statement>
<statement>
<number>AC-1b.2.</number>
<description>
Access control procedures [Assignment: organization-defined frequency].
</description>
</statement>
</statement>
</statement>
<supplemental-guidance>
<description>
This control addresses the establishment of policy and procedures for the effective implementation of selected security controls and control enhancements in the AC family. Policy and procedures reflect applicable federal laws, Executive Orders, directives, regulations, policies, standards, and guidance. Security program policies and procedures at the organization level may make the need for system-specific policies and procedures unnecessary. The policy can be included as part of the general information security policy for organizations or conversely, can be represented by multiple policies reflecting the complex nature of certain organizations. The procedures can be established for the security program in general and for particular information systems, if needed. The organizational risk management strategy is a key factor in establishing policy and procedures.
</description>
<related>PM-9</related>
</supplemental-guidance>
<references>
<reference>
<item xml:lang="en-US" href="https://csrc.nist.gov/publications/search?keywords-lg=800-12">NIST Special Publication 800-12</item>
</reference>
<reference>
<item xml:lang="en-US" href="https://csrc.nist.gov/publications/search?keywords-lg=800-100">NIST Special Publication 800-100</item>
</reference>
</references>
</controls:control>
</controls:controls>