私はprojectDet []という配列を持っています。それは約350の項目が含まれています。python:要素ツリーを持つXML項目の配列を処理することが望ましい "merge"
アレイ内のEACHアイテムは、xml情報(以下の単一項目)です。各項目のxmlは同じ書式ですが、IDと値は異なります。 私が望むのは、要素ツリーを使用して要素を取り除くことができる1つの大きなXML変数にこれらをすべて含めることです。今は要素ツリーを使って配列内の300個のアイテムを調べる方法がわかりません。
IDのXMLの別のセットをチェックするコードがあります。そして、XMLデータAのIDがxmlデータBのIDと一致する場合は、「請求可能な時間」を取り出して最終的なCSV行に追加しますidと一致します。これは、配列内にない他のXMLで動作します。だから私は最も簡単な方法は、私はそれが動作しているコードを使用することですが、私は何らかの形で私は既存の関数にパイプできる1つの変数にこれらのエントリを "マージ"する必要があります。
したがって、この配列をループして各項目を1つのXMLで結合する方法があります。それらはすべて同じツリー構造です。つまり、root/team_member/itemとroot/tasks/itemです。
ありがとうございます。
<root>
<team_members type="list">
<item type="dict">
<id>1137</id>
<cost_rate type="float">76.0</cost_rate>
<budget_spent_percentage type="null" />
<projected_hours type="float">0.0</projected_hours>
<user_id type="int">1351480</user_id>
<total_hours type="float">0.0</total_hours>
<name>Bob R</name>
<budget_left type="null" />
</item>
<item type="dict">
<id>1137</id>
<cost_rate type="null" />
<budget_spent_percentage type="null" />
<projected_hours type="float">2072.0</projected_hours>
<user_id type="null" />
<total_hours type="float">0.0</total_hours>
<name>Samm</name>
<budget_left type="null" />
</item>
</team_members>
<nonbillable_detailed_report_url type="str">/reports/detailed/any</nonbillable_detailed_report_url>
<detailed_report_url type="str">/reports/any</detailed_report_url>
<billable_detailed_report_url type="str">/reports/any</billable_detailed_report_url>
<tasks type="list">
<item type="dict">
<id>1137</id>
<budget_left type="null" />
<budget_spent_percentage type="null" />
<billed_rate type="float">0.0</billed_rate>
<over_budget type="null" />
</item>
<item type="dict">
<id>1137</id>
<budget_left type="null" />
<budget_spent_percentage type="null" />
<billed_rate type="float">0.0</billed_rate>
<over_budget type="null" />
</item>
<item type="dict">
<id>1137</id>
<budget_left type="null" />
<budget_spent_percentage type="null" />
<billed_rate type="float">0.0</billed_rate>
<over_budget type="null" />
<total_hours type="float">0.0</total_hours>
<budget type="null" />
</item>
<item type="dict">
<id>1137</id>
<budget_left type="null" />
<budget_spent_percentage type="null" />
<billed_rate type="float">0.0</billed_rate>
<over_budget type="null" />
<total_hours type="float">0.0</total_hours>
<budget type="null" />
</item>
<item type="dict">
<id>1137</id>
<budget_left type="null" />
<budget_spent_percentage type="null" />
<billed_rate type="float">0.0</billed_rate>
<over_budget type="null" />
<total_hours type="float">0.0</total_hours>
<budget type="null" />
</item>
<item type="dict">
<id>1137</id>
<budget_left type="null" />
<budget_spent_percentage type="null" />
<billed_rate type="float">0.0</billed_rate>
<over_budget type="null" />
<total_hours type="float">0.0</total_hours>
<budget type="null" />
</item>
</tasks>
</root>
ですか? – Parfait
@Parfaitもう一度!私はprojectDet = []を行うことでそれを作成したので、それはリストだと思いますか? –