R:如何将xml中特定节点下的所有标记中的数据提取到csv中

时间:2014-04-15 10:26:29

标签: xml r csv

我尝试从<section>标记下的子树中提取多个文件,这些文件类似于此处的xml文件:http://1.usa.gov/1jHgk28

xml的结构非常复杂,R :: XML无法正确解析它。 我也试过xslt,但也失败了。 我已经在SO上阅读了几个线程,并尝试了xmlTreeParse和xmlParse函数,正如其他用户在几个线程中所建议的那样但没有任何工作。

此外,源代码提供了一些xsd文件,但我不确定如何在数据提取中使用它们。

以下是其中一个xml文件的示例结构:

    <?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="usctitle.css"?>
<uscDoc xsi:schemaLocation="http://xml.house.gov/schemas/uslm/1.0 USLM-1.0.15.xsd" xml:lang="en" identifier="/us/usc/t6" xmlns="http://xml.house.gov/schemas/uslm/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/">
<meta>
  <dc:title>Title 6</dc:title>
  <dc:type>USCTitle</dc:type>
  <docNumber>6</docNumber>
  <docPublicationName>Online@113-52</docPublicationName>
  <dc:publisher>OLRC</dc:publisher>
  <dcterms:created>2013-10-23T11:07:10</dcterms:created>
  <dc:creator>USCConverter 1.1</dc:creator>
</meta>
<main>
<title id="id15642e8c-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6"><num value="6">Title 6—</num><heading>DOMESTIC SECURITY</heading>

<chapter style="-uslm-lc:I81" id="id15691091-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/ch1"><num value="1">CHAPTER 1—</num><heading>HOMELAND SECURITY ORGANIZATION</heading>
<toc role="twoColumnTOC" id="id15691092-3bf5-11e3-bb07-92325430929f">
<layout>
<header style="-uslm-lc:I70" role="tocColumnHeader">
<column class="tocHeaderLeft">Sec.</column>
</header>

<section status="repealed" style="-uslm-lc:I80" id="id15db3312-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s371"><num value="371">§ 371.</num><heading> Repealed. <ref href="/us/pl/108/7/s104/c/1">Pub. L. 108–7, div. L, § 104(c)(1)</ref>, <date date="2003-02-20">Feb. 20, 2003</date>, <ref href="/us/stat/117/531">117 Stat. 531</ref></heading><notes type="uscNote" id="id15dda413-3bf5-11e3-bb07-92325430929f">
<note topic="removalDescription" id="id15dda414-3bf5-11e3-bb07-92325430929f">
<p style="-uslm-lc:I21" class="indent0">Section, <ref href="/us/pl/107/296/s811">Pub. L. 107–296, title VIII, § 811</ref>, <date date="2002-11-25">Nov. 25, 2002</date>, <ref href="/us/stat/116/2221">116 Stat. 2221</ref>, related to authority of Secretary of Homeland Security with respect to Inspector General.</p>
</note>
</notes>
</section>

<section style="-uslm-lc:I80" id="id16608fdb-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402"><num value="1402">§ 1402.</num><heading> Port of Entry Infrastructure Assessment Study</heading><subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id16608fdc-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/a"><num value="a">(a)</num><heading> Requirement to update</heading><chapeau>Not later than January 31 of every other year, the Commissioner, in consultation with the Administrator of General Services shall—</chapeau><paragraph style="-uslm-lc:I12" class="indent1" id="id16608fdd-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/a/1"><num value="1">(1)</num><chapeau> review—</chapeau><subparagraph style="-uslm-lc:I13" class="indent2" id="id16608fde-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/a/1/A"><num value="A">(A)</num><content> the Port of Entry Infrastructure Assessment Study prepared by the United States Customs Service, the Immigration and Naturalization Service, and the General Services Administration in accordance with the matter relating to the ports of entry infrastructure assessment set forth in the joint explanatory statement on page 67 of conference report 106–319, accompanying <ref href="/us/pl/106/58">Public Law 106–58</ref>; and</content>
</subparagraph>
<subparagraph style="-uslm-lc:I13" class="indent2" id="id16608fdf-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/a/1/B"><num value="B">(B)</num><content> the nationwide strategy to prioritize and address the infrastructure needs at the land ports of entry prepared by the Department of Homeland Security and the General Services Administration in accordance with the committee recommendations on page 22 of Senate report 108–86, accompanying <ref href="/us/pl/108/90">Public Law 108–90</ref>;</content>
</subparagraph>
</paragraph>
<paragraph style="-uslm-lc:I12" class="indent1" id="id16608fe0-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/a/2"><num value="2">(2)</num><content> update the assessment of the infrastructure needs of all United States land ports of entry; and</content>
</paragraph>
<paragraph style="-uslm-lc:I12" class="indent1" id="id16608fe1-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/a/3"><num value="3">(3)</num><content> submit an updated assessment of land port of entry infrastructure needs to the Committees on Appropriations of the Senate and the House of Representatives, the Senate Committee on Environment and Public Works, the Senate Committee on Homeland Security and Governmental Affairs, the House Committee on Transportation and Infrastructure, and the House Committee on Homeland Security.</content>
</paragraph>
</subsection>
<subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id16608fe2-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/b"><num value="b">(b)</num><heading> Consultation</heading><content><p style="-uslm-lc:I11" class="indent0">In preparing the updated studies required under subsection (a), the Commissioner and the Administrator of General Services shall consult with the Director of the Office of Management and Budget, the Secretary, and affected State and local agencies on the northern and southern borders of the United States.</p>
</content>
</subsection>
<subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id16608fe3-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/c"><num value="c">(c)</num><heading> Content</heading><chapeau>Each updated study required in subsection (a) shall—</chapeau><paragraph style="-uslm-lc:I12" class="indent1" id="id16608fe4-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/c/1"><num value="1">(1)</num><content> identify port of entry infrastructure and technology improvement projects that would enhance border security and facilitate the flow of legitimate commerce if implemented;</content>
</paragraph>
<paragraph style="-uslm-lc:I12" class="indent1" id="id16608fe5-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/c/2"><num value="2">(2)</num><content> include the projects identified in the National Land Border Security Plan required by <ref href="/us/usc/t6/s1403">section 1403 of this title</ref>; and</content>
</paragraph>
<paragraph style="-uslm-lc:I12" class="indent1" id="id16608fe6-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/c/3"><num value="3">(3)</num><chapeau> prioritize the projects described in paragraphs (1) and (2) based on the ability of a project—</chapeau><subparagraph style="-uslm-lc:I13" class="indent2" id="id16608fe7-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/c/3/A"><num value="A">(A)</num><content> to enhance the ability of U.S. Customs and Border Protection to achieve its mission and to support operations;</content>
</subparagraph>
<subparagraph style="-uslm-lc:I13" class="indent2" id="id16608fe8-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/c/3/B"><num value="B">(B)</num><content> to fulfill security requirements; and</content>
</subparagraph>
<subparagraph style="-uslm-lc:I13" class="indent2" id="id16608fe9-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/c/3/C"><num value="C">(C)</num><content> facilitate trade across the borders of the United States.</content>
</subparagraph>
</paragraph>
</subsection>
<subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id16608fea-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/d"><num value="d">(d)</num><heading> Project implementation</heading><chapeau>The Commissioner, as appropriate, shall—</chapeau><paragraph style="-uslm-lc:I12" class="indent1" id="id16608feb-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/d/1"><num value="1">(1)</num><content> implement the infrastructure and technology improvement projects described in subsection (c) in the order of priority assigned to each project under subsection (c)(3); or</content>
</paragraph>
<paragraph style="-uslm-lc:I12" class="indent1" id="id16608fec-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/d/2"><num value="2">(2)</num><content> forward the prioritized list of infrastructure and technology improvement projects to the Administrator of General Services for implementation in the order of priority assigned to each project under subsection (c)(3).</content>
</paragraph>
</subsection>
<subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id16608fed-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1402/e"><num value="e">(e)</num><heading> Divergence from priorities</heading><content><p style="-uslm-lc:I11" class="indent0">The Commissioner may diverge from the priority order if the Commissioner determines that significantly changed circumstances, including immediate security needs, changes in infrastructure in Mexico or Canada, or similar concerns, compellingly alter the need for a project in the United States.</p>
</content>
</subsection>
<sourceCredit id="id16608fee-3bf5-11e3-bb07-92325430929f">(<ref href="/us/pl/110/161/s603">Pub. L. 110–161, div. E, title VI, § 603</ref>, <date date="2007-12-26">Dec. 26, 2007</date>, <ref href="/us/stat/121/2094">121 Stat. 2094</ref>.)</sourceCredit>
<notes type="uscNote" id="id16608fef-3bf5-11e3-bb07-92325430929f">
<note style="-uslm-lc:I75" topic="referencesInText" id="id16608ff0-3bf5-11e3-bb07-92325430929f">
<heading class="centered smallCaps">References in Text</heading><p style="-uslm-lc:I21" class="indent0"><ref href="/us/pl/106/58">Public Law 106–58</ref>, referred to in subsec. (a)(1)(A), is <ref href="/us/pl/106/58">Pub. L. 106–58</ref>, <date date="1999-09-29">Sept. 29, 1999</date>, <ref href="/us/stat/113/430">113 Stat. 430</ref>, known as the Treasury and General Government Appropriations Act, 2000. For complete classification of this Act to the Code, see Tables.</p>
<p style="-uslm-lc:I21" class="indent0"><ref href="/us/pl/108/90">Public Law 108–90</ref>, referred to in subsec. (a)(1)(B), is <ref href="/us/pl/108/90">Pub. L. 108–90</ref>, <date date="2003-10-01">Oct. 1, 2003</date>, <ref href="/us/stat/117/1137">117 Stat. 1137</ref>, known as the Department of Homeland Security Appropriations Act, 2004. For complete classification of this Act to the Code, see Tables.</p>
</note>
</notes>
</section>
<section style="-uslm-lc:I80" id="id16608ff1-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1403"><num value="1403">§ 1403.</num><heading> National Land Border Security Plan</heading><subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id16608ff2-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1403/a"><num value="a">(a)</num><heading> Requirement for plan</heading><content><p style="-uslm-lc:I11" class="indent0">Not later than January 31 of every other year, the Secretary, acting through the Commissioner, shall prepare a National Land Border Security Plan and submit such plan to the Committees on Appropriations of the Senate and the House of Representatives, the Senate Committee on Environment and Public Works, the Senate Committee on Homeland Security and Governmental Affairs, the Senate Committee on the Judiciary, the House Committee on Transportation and Infrastructure, the House Committee on Homeland Security, and the House Committee on the Judiciary.</p>
</content>
</subsection>
<subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id16608ff3-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1403/b"><num value="b">(b)</num><heading> Consultation</heading><content><p style="-uslm-lc:I11" class="indent0">In preparing the plan required under subsection (a), the Commissioner shall consult with other appropriate Federal agencies, State and local law enforcement agencies, and private entities that are involved in international trade across the northern or southern border.</p>
</content>
</subsection>
<subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id16608ff4-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1403/c"><num value="c">(c)</num><heading> Vulnerability assessment</heading><paragraph style="-uslm-lc:I79" class="indent3 firstIndent-2 bold" id="id16608ff5-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1403/c/1"><num value="1">(1)</num><heading> In general</heading><content><p style="-uslm-lc:I12" class="indent1">The plan required under subsection (a) shall include a vulnerability, risk, and threat assessment of each port of entry located on the northern border or the southern border.</p>
</content>
</paragraph>
<paragraph style="-uslm-lc:I79" class="indent3 firstIndent-2 bold" id="id16608ff6-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1403/c/2"><num value="2">(2)</num><heading> Port security coordinators</heading><chapeau>The Secretary, acting through the Commissioner, may establish one or more port security coordinators at each port of entry located on the northern border or the southern border—</chapeau><subparagraph style="-uslm-lc:I13" class="indent2" id="id16608ff7-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1403/c/2/A"><num value="A">(A)</num><content> to assist in conducting a vulnerability assessment at such port; and</content>
</subparagraph>
<subparagraph style="-uslm-lc:I13" class="indent2" id="id16608ff8-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1403/c/2/B"><num value="B">(B)</num><content> to provide other assistance with the preparation of the plan required under subsection (a).</content>
</subparagraph>
</paragraph>
</subsection>
<subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id16608ff9-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1403/d"><num value="d">(d)</num><heading> Coordination with the Secure Border Initiative</heading><content><p style="-uslm-lc:I11" class="indent0">The plan required under subsection (a) shall include a description of activities undertaken during the previous year as part of the Secure Border Initiative and actions planned for the coming year as part of the Secure Border Initiative.</p>
</content>
</subsection>
<sourceCredit id="id16608ffa-3bf5-11e3-bb07-92325430929f">(<ref href="/us/pl/110/161/s604">Pub. L. 110–161, div. E, title VI, § 604</ref>, <date date="2007-12-26">Dec. 26, 2007</date>, <ref href="/us/stat/121/2095">121 Stat. 2095</ref>.)</sourceCredit>
</section>
<section style="-uslm-lc:I80" id="id16608ffb-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404"><num value="1404">§ 1404.</num><heading> Port of entry technology demonstration program</heading><subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id16608ffc-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/a"><num value="a">(a)</num><heading> Establishment</heading><content><p style="-uslm-lc:I11" class="indent0">The Secretary, acting through the Commissioner, shall carry out a technology demonstration program to test and evaluate new port of entry technologies, refine port of entry technologies and operational concepts, and train personnel under realistic conditions.</p>
</content>
</subsection>
<subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id16608ffd-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/b"><num value="b">(b)</num><heading> Technology tested</heading><content><p style="-uslm-lc:I11" class="indent0">Under the demonstration program, the Commissioner shall test technologies that enhance port of entry operations, including those related to inspections, communications, port tracking, identification of persons and cargo, sensory devices, personal detection, decision support, and the detection and identification of weapons of mass destruction.</p>
</content>
</subsection>
<subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id16608ffe-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/c"><num value="c">(c)</num><heading> Demonstration sites</heading><paragraph style="-uslm-lc:I79" class="indent3 firstIndent-2 bold" id="id16608fff-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/c/1"><num value="1">(1)</num><heading> Number</heading><content><p style="-uslm-lc:I12" class="indent1">The Commissioner shall carry out the demonstration program at not less than three sites and not more than five sites.</p>
</content>
</paragraph>
<paragraph style="-uslm-lc:I79" class="indent3 firstIndent-2 bold" id="id16609000-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/c/2"><num value="2">(2)</num><heading> Location</heading><chapeau>Of the sites selected under subsection (c)—</chapeau><subparagraph style="-uslm-lc:I13" class="indent2" id="id16609001-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/c/2/A"><num value="A">(A)</num><content> at least one shall be located on the northern border of the United States; and</content>
</subparagraph>
<subparagraph style="-uslm-lc:I13" class="indent2" id="id16609002-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/c/2/B"><num value="B">(B)</num><content> at least one shall be located on the southern border of the United States.</content>
</subparagraph>
</paragraph>
<paragraph style="-uslm-lc:I79" class="indent3 firstIndent-2 bold" id="id16630103-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/c/3"><num value="3">(3)</num><heading> Selection criteria</heading><chapeau>To ensure that one of the facilities selected as a port of entry demonstration site for the demonstration program has the most up-to-date design, contains sufficient space to conduct the demonstration program, has a traffic volume low enough to easily incorporate new technologies without interrupting normal processing activity, and can efficiently carry out demonstration and port of entry operations, one port of entry selected as a demonstration site may—</chapeau><subparagraph style="-uslm-lc:I13" class="indent2" id="id16630104-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/c/3/A"><num value="A">(A)</num><content> have been established not more than 15 years before <date date="2007-12-26">December 26, 2007</date>;</content>
</subparagraph>
<subparagraph style="-uslm-lc:I13" class="indent2" id="id16630105-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/c/3/B"><num value="B">(B)</num><content> consist of not less than 65 acres, with the possibility of expansion onto not less than 25 adjacent acres; and</content>
</subparagraph>
<subparagraph style="-uslm-lc:I13" class="indent2" id="id16630106-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/c/3/C"><num value="C">(C)</num><content> have serviced an average of not more than 50,000 vehicles per month during the 12 months preceding <date date="2007-12-26">December 26, 2007</date>.</content>
</subparagraph>
</paragraph>
</subsection>
<subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id16630107-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/d"><num value="d">(d)</num><heading> Relationship with other agencies</heading><content><p style="-uslm-lc:I11" class="indent0">The Secretary, acting through the Commissioner, shall permit personnel from appropriate Federal agencies to utilize a demonstration site described in subsection (c) to test technologies that enhance port of entry operations, including those related to inspections, communications, port tracking, identification of persons and cargo, sensory devices, personal detection, decision support, and the detection and identification of weapons of mass destruction.</p>
</content>
</subsection>
<subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id16630108-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/e"><num value="e">(e)</num><heading> Report</heading><paragraph style="-uslm-lc:I79" class="indent3 firstIndent-2 bold" id="id16630109-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/e/1"><num value="1">(1)</num><heading> Requirement</heading><content><p style="-uslm-lc:I12" class="indent1">Not later than 1 year after <date date="2007-12-26">December 26, 2007</date>, and annually thereafter, the Secretary shall submit to the Committees on Appropriations of the Senate and the House of Representatives, the Senate Committee on Environment and Public Works, the Senate Committee on Homeland Security and Governmental Affairs, the House Committee on Transportation and Infrastructure, and the House Committee on Homeland Security a report on the activities carried out at each demonstration site under the technology demonstration program established under this section.</p>
</content>
</paragraph>
<paragraph style="-uslm-lc:I79" class="indent3 firstIndent-2 bold" id="id1663010a-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1404/e/2"><num value="2">(2)</num><heading> Content</heading><content><p style="-uslm-lc:I12" class="indent1">The report shall include an assessment by the Commissioner of the feasibility of incorporating any demonstrated technology for use throughout U.S. Customs and Border Protection.</p>
</content>
</paragraph>
</subsection>
<sourceCredit id="id1663010b-3bf5-11e3-bb07-92325430929f">(<ref href="/us/pl/110/161/s605">Pub. L. 110–161, div. E, title VI, § 605</ref>, <date date="2007-12-26">Dec. 26, 2007</date>, <ref href="/us/stat/121/2096">121 Stat. 2096</ref>.)</sourceCredit>
</section>
<section style="-uslm-lc:I80" id="id1663010c-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1405"><num value="1405">§ 1405.</num><heading> Authorization of appropriations</heading><subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id1663010d-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1405/a"><num value="a">(a)</num><heading> In general</heading><content><p style="-uslm-lc:I11" class="indent0">In addition to any funds otherwise available, there are authorized to be appropriated such sums as may be necessary to carry out this chapter for fiscal years 2009 through 2013.</p>
</content>
</subsection>
<subsection style="-uslm-lc:I19" class="indent2 firstIndent-2 bold" id="id1663010e-3bf5-11e3-bb07-92325430929f" identifier="/us/usc/t6/s1405/b"><num value="b">(b)</num><heading> International agreements</heading><content><p style="-uslm-lc:I11" class="indent0">Funds authorized to be appropriated under this chapter may be used for the implementation of projects described in the Declaration on Embracing Technology and Cooperation to Promote the Secure and Efficient Flow of People and Commerce across our Shared Border between the United States and Mexico, agreed to <date date="2002-03-22">March 22, 2002</date>, Monterrey, Mexico (commonly known as the Border Partnership Action Plan) or the Smart Border Declaration between the United States and Canada, agreed to <date date="2001-12-12">December 12, 2001</date>, Ottawa, Canada that are consistent with the provisions of this chapter.</p>
</content>
</subsection>
<sourceCredit id="id1663010f-3bf5-11e3-bb07-92325430929f">(<ref href="/us/pl/110/161/s606">Pub. L. 110–161, div. E, title VI, § 606</ref>, <date date="2007-12-26">Dec. 26, 2007</date>, <ref href="/us/stat/121/2097">121 Stat. 2097</ref>.)</sourceCredit>
</section>
</chapter>
</title>
</main>
</uscDoc>

我想将以下格式的节节点下的数据提取到csv文件中:

部分(num值),标题(文本),内容(文本)

此问题与大多数情况的不同之处在于输出的内容部分包含节点下所有标记下的文本。

非常感谢任何处理这方面的帮助。

1 个答案:

答案 0 :(得分:0)

我希望这肯定会帮助您访问xml标记的属性。我是通过使用simplexml完成​​的。

<?php
$SimpleXML = simplexml_load_file("usc06.xml");
$attributesContainer = array();
echo "<pre>";
$attributes = $SimpleXML->main->title->chapter->section->attributes();
print_r($attributes);
echo "Style : " . $attributes->style ." ID : " . $attributes->style . " Identifier : " .         $attributes->identifier;