我想解析多个XML文件到列/表,但一些XML有不同的数据,有些不重要,而其他数据是重要的。解析选择xml数据到列使用python
即(XML数据):
<setId root="ABD6ECF0-DC8E"/>
<component>
<section>
<id root="F08C6A14-8165-458A-BDC8-0B5878EB814D"/>
<code code="34069-5" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="HOW SUPPLIED SECTION"/>
<title mediaType="text/x-hl7-title+xml">HOW SUPPLIED</title>
<text>
<paragraph>RENESE (polythiazide) Tablets are available as:</paragraph>
<paragraph>1 mg white, scored tablets in bottles of 100 (NDC 0069-3750-66).</paragraph>
<paragraph>2 mg yellow, scored tablets in bottles of 100 (NDC 0069-3760-66).</paragraph>
<paragraph>4 mg white, scored tablets in bottles of 100 (NDC 0069-3770-66).</paragraph>
</text>
<effectiveTime value="20051214"/>
</section>
</component>
<component>
<section>
<id root="42CB916B-BB58-44A0-B8D2-89B4B27F04DF"/>
<code code="34089-3" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="DESCRIPTION SECTION"/>
<title mediaType="text/x-hl7-title+xml">DESCRIPTION</title>
<text>
<paragraph>Renese<sup>®</sup> is designated generically as polythiazide, and chemically as 2<content styleCode="italics">H</content>-1,2,4-Benzothiadiazine-7-sulfonamide, 6-chloro-3,4-dihydro-2-methyl-3-[[(2,2,2-trifluoroethyl)thio]methyl]-, 1,1-dioxide. It is a white crystalline substance, insoluble in water but readily soluble in alkaline solution.</paragraph>
<paragraph>Inert Ingredients: dibasic calcium phosphate; lactose; magnesium stearate; polyethylene glycol; sodium lauryl sulfate; starch; vanillin. The 2 mg tablets also contain: Yellow 6; Yellow 10.</paragraph>
</text>
<effectiveTime value="20051214"/>
</section>
</component>
<component>
<section>
<manufacturedProduct>
<manufacturedMedicine>
<code code="0069-3750" codeSystem="2.16.840.1.113883.6.69" codeSystemName="FDA" displayName="NDC"/>
<name>Renese</name>
<formCode code="C42998" codeSystem="2.16.840.1.113883.3.26.1.1" displayName="TABLET"/>
<manufacturedProduct/>
<manufacturedMedicine/>
我想最终的结果是这样的(如在SETID,描述和名称是列名):
SETID
ABD6ECF0-DC8E
描述
Renese被一般性地指定为
多噻,和化学如2H-1,2,4-苯并噻二嗪 -7-磺酰胺,6-氯 -3,4-二氢-2-甲基-3 - [[ (2,2,2,0-三氟乙基)硫代]甲基] - 1,1,1-二氧化物。它是一种白色结晶物质,不溶于水,但易溶于碱性溶液。
名
Renese