我正在try 将格式如下的XML文件加载到数据表:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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="2017-08-01"
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>POLICY AND PROCEDURES</title>
<baseline>LOW</baseline>
<baseline>MODERATE</baseline>
<baseline>HIGH</baseline>
<baseline>PRIVACY</baseline>
<statement>
<description/>
<statement>
<number>AC-1a.</number>
<description>Develop, document, and disseminate to [Assignment: organization-defined personnel or roles]:</description>
<statement>
<number>AC-1a.1.</number>
<description>[Selection (one or more): Organization-level; Mission/business process-level; System-level] access control policy that:</description>
<statement>
<number>AC-1a.1.(a)</number>
<description>Addresses purpose, scope, roles, responsibilities, management commitment, coordination among organizational entities, and compliance; and</description>
</statement>
<statement>
<number>AC-1a.1.(b)</number>
<description>Is consistent with applicable laws, executive orders, directives, regulations, policies, standards, and guidelines; and</description>
</statement>
</statement>
<statement>
<number>AC-1a.2.</number>
<description>Procedures to facilitate the implementation of the access control policy and the associated access controls;</description>
</statement>
</statement>
<statement>
<number>AC-1b.</number>
<description>Designate an [Assignment: organization-defined official] to manage the development, documentation, and dissemination of the access control policy and procedures; and</description>
</statement>
<statement>
<number>AC-1c.</number>
<description>Review and update the current access control:</description>
<statement>
<number>AC-1c.1.</number>
<description>Policy [Assignment: organization-defined frequency] and following [Assignment: organization-defined events]; and</description>
</statement>
<statement>
<number>AC-1c.2.</number>
<description>Procedures [Assignment: organization-defined frequency] and following [Assignment: organization-defined events].</description>
</statement>
</statement>
</statement>
</controls:control>
我能够提取家庭和其他值,但当我试图访问这些语句时,我什么也得不到.我需要创建一个表,其中每个语句值都在一行中,父值也在该行中,如Family和TITLE.
这就是我所得到的:
string ns = "http://scap.nist.gov/schema/sp800-53/feed/2.0";
XDocument xdoc = XDocument.Load("80053.xml");
var ccidata = xdoc.Descendants(XName.Get("control", ns))
.Descendants("statement")
.Select(i => new
{
family = i?.Parent?.Element("family")?.Value,
number = i?.Element("number")?.Value,
}).ToList();
如果您能给我指点,我将不胜感激.