我尝试使用下面的代码从XML下面删除scheme-details1,但无法删除。
XmlActionResult xmlActionResult = new XmlActionResult(schememaster);
foreach (XElement element in xmlActionResult._document.Elements())
{
xmlActionResult._document.Elements("scheme-details1").Remove();
}
其中XMLActionResult._Document
是XDocument
。
以下是我的XML响应:-
<scheme-master>
<general-information>
<schemecode>XXXXX</schemecode>
<year>2020</year>
<month>04</month>
<requestid>0008052020</requestid>
</general-information>
<scheme-details1>
<scheme-details>
<location>
<district_code>503</district_code>
<district_name>Chittoor</district_name>
<state_code>28</state_code>
<state_name>Andhra pradesh</state_name>
</location>
<beneficiary-details>
<no_of_beneficiaries_normative_central_and_state_share>10000</no_of_beneficiaries_normative_central_and_state_share>
<no_of_additional_beneficiaries_supported_by_state>0</no_of_additional_beneficiaries_supported_by_state>
<total_no_of_beneficiaries>10000</total_no_of_beneficiaries>
<no_of_beneficiaries_record_digitized>10000</no_of_beneficiaries_record_digitized>
<no_of_authenticated_seeded_beneficiaries>10000</no_of_authenticated_seeded_beneficiaries>
<no_of_beneficiaries_whom_mobile_no_captured>10000</no_of_beneficiaries_whom_mobile_no_captured>
</beneficiary-details>
<fundtransfer-details>
<central_share_fund_transferred_cash>10000</central_share_fund_transferred_cash>
<normative_state_share_fund_transferred_cash>0</normative_state_share_fund_transferred_cash>
<additional_state_share_fund_transferred_cash>0</additional_state_share_fund_transferred_cash>
<state_share_fund_transferred_to_additional_beneficiaries_cash>0</state_share_fund_transferred_to_additional_beneficiaries_cash>
<total_fund_transferred_cash>10000</total_fund_transferred_cash>
<central_share_expenditure_incurred_inkind>0</central_share_expenditure_incurred_inkind>
<normative_state_share_expenditure_incurred_inkind>0</normative_state_share_expenditure_incurred_inkind>
<additional_state_share_expenditure_incurred_inkind>0</additional_state_share_expenditure_incurred_inkind>
<state_share_expenditure_incurred_to_additional_beneficiaries_inkind>0</state_share_expenditure_incurred_to_additional_beneficiaries_inkind>
<total_expenditure_incurred_inkind>0</total_expenditure_incurred_inkind>
</fundtransfer-details>
<transaction-details>
<total_no_transactions_electronic_modes_cash>10000</total_no_transactions_electronic_modes_cash>
<payment_electronic_modes_cash>10000</payment_electronic_modes_cash>
<total_no_transactions_other_modes_cash>0</total_no_transactions_other_modes_cash>
<payment_other_modes_cash>0</payment_other_modes_cash>
<quantity_transferred_inkind>0</quantity_transferred_inkind>
<no_of_authenticated_transactions_inkind>0</no_of_authenticated_transactions_inkind>
<dbt_expenditure_incurred_inkind>0</dbt_expenditure_incurred_inkind>
</transaction-details>
</scheme-details>
<scheme-details>
<location>
<district_code>504</district_code>
<district_name>Cuddapah (YSR Kadapa)</district_name>
<state_code>28</state_code>
<state_name>Andhra pradesh</state_name>
</location>
<beneficiary-details>
<no_of_beneficiaries_normative_central_and_state_share>10000</no_of_beneficiaries_normative_central_and_state_share>
<no_of_additional_beneficiaries_supported_by_state>0</no_of_additional_beneficiaries_supported_by_state>
<total_no_of_beneficiaries>10000</total_no_of_beneficiaries>
<no_of_beneficiaries_record_digitized>10000</no_of_beneficiaries_record_digitized>
<no_of_authenticated_seeded_beneficiaries>10000</no_of_authenticated_seeded_beneficiaries>
<no_of_beneficiaries_whom_mobile_no_captured>10000</no_of_beneficiaries_whom_mobile_no_captured>
</beneficiary-details>
<fundtransfer-details>
<central_share_fund_transferred_cash>10000</central_share_fund_transferred_cash>
<normative_state_share_fund_transferred_cash>0</normative_state_share_fund_transferred_cash>
<additional_state_share_fund_transferred_cash>0</additional_state_share_fund_transferred_cash>
<state_share_fund_transferred_to_additional_beneficiaries_cash>0</state_share_fund_transferred_to_additional_beneficiaries_cash>
<total_fund_transferred_cash>10000</total_fund_transferred_cash>
<central_share_expenditure_incurred_inkind>0</central_share_expenditure_incurred_inkind>
<normative_state_share_expenditure_incurred_inkind>0</normative_state_share_expenditure_incurred_inkind>
<additional_state_share_expenditure_incurred_inkind>0</additional_state_share_expenditure_incurred_inkind>
<state_share_expenditure_incurred_to_additional_beneficiaries_inkind>0</state_share_expenditure_incurred_to_additional_beneficiaries_inkind>
<total_expenditure_incurred_inkind>0</total_expenditure_incurred_inkind>
</fundtransfer-details>
<transaction-details>
<total_no_transactions_electronic_modes_cash>10000</total_no_transactions_electronic_modes_cash>
<payment_electronic_modes_cash>10000</payment_electronic_modes_cash>
<total_no_transactions_other_modes_cash>0</total_no_transactions_other_modes_cash>
<payment_other_modes_cash>0</payment_other_modes_cash>
<quantity_transferred_inkind>0</quantity_transferred_inkind>
<no_of_authenticated_transactions_inkind>0</no_of_authenticated_transactions_inkind>
<dbt_expenditure_incurred_inkind>0</dbt_expenditure_incurred_inkind>
</transaction-details>
</scheme-details>
<scheme-details>
<location>
<district_code>503</district_code>
<district_name>Chittoor</district_name>
<state_code>28</state_code>
<state_name>Andhra pradesh</state_name>
</location>
<beneficiary-details>
<no_of_beneficiaries_normative_central_and_state_share>10000</no_of_beneficiaries_normative_central_and_state_share>
<no_of_additional_beneficiaries_supported_by_state>0</no_of_additional_beneficiaries_supported_by_state>
<total_no_of_beneficiaries>10000</total_no_of_beneficiaries>
<no_of_beneficiaries_record_digitized>10000</no_of_beneficiaries_record_digitized>
<no_of_authenticated_seeded_beneficiaries>10000</no_of_authenticated_seeded_beneficiaries>
<no_of_beneficiaries_whom_mobile_no_captured>10000</no_of_beneficiaries_whom_mobile_no_captured>
</beneficiary-details>
<fundtransfer-details>
<central_share_fund_transferred_cash>10000</central_share_fund_transferred_cash>
<normative_state_share_fund_transferred_cash>0</normative_state_share_fund_transferred_cash>
<additional_state_share_fund_transferred_cash>0</additional_state_share_fund_transferred_cash>
<state_share_fund_transferred_to_additional_beneficiaries_cash>0</state_share_fund_transferred_to_additional_beneficiaries_cash>
<total_fund_transferred_cash>10000</total_fund_transferred_cash>
<central_share_expenditure_incurred_inkind>0</central_share_expenditure_incurred_inkind>
<normative_state_share_expenditure_incurred_inkind>0</normative_state_share_expenditure_incurred_inkind>
<additional_state_share_expenditure_incurred_inkind>0</additional_state_share_expenditure_incurred_inkind>
<state_share_expenditure_incurred_to_additional_beneficiaries_inkind>0</state_share_expenditure_incurred_to_additional_beneficiaries_inkind>
<total_expenditure_incurred_inkind>0</total_expenditure_incurred_inkind>
</fundtransfer-details>
<transaction-details>
<total_no_transactions_electronic_modes_cash>10000</total_no_transactions_electronic_modes_cash>
<payment_electronic_modes_cash>10000</payment_electronic_modes_cash>
<total_no_transactions_other_modes_cash>0</total_no_transactions_other_modes_cash>
<payment_other_modes_cash>0</payment_other_modes_cash>
<quantity_transferred_inkind>0</quantity_transferred_inkind>
<no_of_authenticated_transactions_inkind>0</no_of_authenticated_transactions_inkind>
<dbt_expenditure_incurred_inkind>0</dbt_expenditure_incurred_inkind>
</transaction-details>
</scheme-details>
<scheme-details>
<location>
<district_code>504</district_code>
<district_name>Cuddapah (YSR Kadapa)</district_name>
<state_code>28</state_code>
<state_name>Andhra pradesh</state_name>
</location>
<beneficiary-details>
<no_of_beneficiaries_normative_central_and_state_share>10000</no_of_beneficiaries_normative_central_and_state_share>
<no_of_additional_beneficiaries_supported_by_state>0</no_of_additional_beneficiaries_supported_by_state>
<total_no_of_beneficiaries>10000</total_no_of_beneficiaries>
<no_of_beneficiaries_record_digitized>10000</no_of_beneficiaries_record_digitized>
<no_of_authenticated_seeded_beneficiaries>10000</no_of_authenticated_seeded_beneficiaries>
<no_of_beneficiaries_whom_mobile_no_captured>10000</no_of_beneficiaries_whom_mobile_no_captured>
</beneficiary-details>
<fundtransfer-details>
<central_share_fund_transferred_cash>10000</central_share_fund_transferred_cash>
<normative_state_share_fund_transferred_cash>0</normative_state_share_fund_transferred_cash>
<additional_state_share_fund_transferred_cash>0</additional_state_share_fund_transferred_cash>
<state_share_fund_transferred_to_additional_beneficiaries_cash>0</state_share_fund_transferred_to_additional_beneficiaries_cash>
<total_fund_transferred_cash>10000</total_fund_transferred_cash>
<central_share_expenditure_incurred_inkind>0</central_share_expenditure_incurred_inkind>
<normative_state_share_expenditure_incurred_inkind>0</normative_state_share_expenditure_incurred_inkind>
<additional_state_share_expenditure_incurred_inkind>0</additional_state_share_expenditure_incurred_inkind>
<state_share_expenditure_incurred_to_additional_beneficiaries_inkind>0</state_share_expenditure_incurred_to_additional_beneficiaries_inkind>
<total_expenditure_incurred_inkind>0</total_expenditure_incurred_inkind>
</fundtransfer-details>
<transaction-details>
<total_no_transactions_electronic_modes_cash>10000</total_no_transactions_electronic_modes_cash>
<payment_electronic_modes_cash>10000</payment_electronic_modes_cash>
<total_no_transactions_other_modes_cash>0</total_no_transactions_other_modes_cash>
<payment_other_modes_cash>0</payment_other_modes_cash>
<quantity_transferred_inkind>0</quantity_transferred_inkind>
<no_of_authenticated_transactions_inkind>0</no_of_authenticated_transactions_inkind>
<dbt_expenditure_incurred_inkind>0</dbt_expenditure_incurred_inkind>
</transaction-details>
</scheme-details>
</scheme-details1>
</scheme-master>
您正在循环访问XDocument
的XElement Element
根节点,但尝试从文档本身删除
节点。而是从当前的元素
中删除它们:
foreach (var element in xmlActionResult._document.Elements())
{
//xmlActionResult._document.Elements("scheme-details1").Remove(); // FIXED
element.Elements("scheme-details1").Remove();
}
或者,由于格式良好的XML文档总是只有一个根元素,您可以省去根元素的循环,只需执行以下操作:
xmlActionResult._document.Root.Elements("scheme-details1").Remove();
这里是演示。
问题内容: 这段代码是一个表,可以选择“惰性名称”,“删除”,“显示”和“退出”。 该代码运行良好,但是我唯一的问题是如何删除节点中的所选名称 *我不知道如何删除节点。我应该在删除方法上加上什么? 问题答案: 要删除Node,您实际上需要更新它的上一个节点的位置以删除Node的位置,而剩下的Node最终将被垃圾回收。 如果要删除的节点是根节点,则只有一个问题,然后更新根节点。
我有一个单链表。如果我想从这个链表中删除一个已知的元素,我能做什么? 例如:节点*头;(44)节点*尾部;(39) 链接列表:44 27 59 13 45 39我们想从中删除45。得到:4427591339 我只知道从列表中删除第一个元素(如果元素(需要删除)是列表的第一个元素)。我得到了:头=头- 如何从列表中删除中间节点?
问题内容: 我有一个清单,里面有空清单: 如何删除空列表,以便获得: 我尝试了list.remove(’‘),但这不起作用。 问题答案: 尝试 如果您想摆脱所有“虚假”的东西,例如空字符串,空元组,零,您也可以使用
我最近开始发现Databricks,并面临需要删除增量表的某个列的情况。当我使用后格雷SQL时,它就像 我正在浏览有关删除的数据砖文档,但它仅涵盖。 我还找到了关于DROP数据库、DROP函数和DROP表的文档,但对于如何从delta表中删除列却一无所知。我在这里错过了什么?是否有标准的方法从delta表中删除列?
我有麻烦删除双向链表中的节点,程序崩溃,我不能解决这个问题。你能帮我吗?这是创建新节点,查看它们并删除它们的完整代码。 我认为这个问题与Node del的scanf()有关,但我不确定。当我只是通过或
问题内容: 假设Oracle 10G中有两个表 TableA中的每一行在TableB中都有与其相关的几个子行。 我想删除TableA中的特定行,这意味着我必须先删除tableB中的相关行。 这将删除子条目 要删除子表中刚刚删除的行的父行,我可以这样做 上面还将删除子表中的行,其中(last_update_Dtm = sysdate-30)为false。TableA没有last_update_dtm