我有一个像下面这样的xml:
def retrieve(self, request, *args, **kwargs):
"""Retrieve a FooBar"""
return super().retrieve(request, *args, **kwargs)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns4:EligibilityRequest xmlns:ns5="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/eligresponse" xmlns:ns1="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/mmiscommon" xmlns:ns4="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/eligrequest" xmlns:ns3="http://xmlns.eohhs.ma.gov/newMMIS/ws/2006/05/MemberInfo">
<ns4:transactionsource id_medicaid="100027128782" id_other="00001740934" id_source="HIX"/>
<ns4:demographic dte_birth="1986-10-24" cde_sex="F" num_primary_ssn="031725754" cde_citizen="C" cde_race="UNKNOW" cde_ethnicity="UNKNOW" cde_homeless="N" cde_primary_lang="ENG" cde_lang_written="ENG" num_phone_day="4135376954" email="slpaullrn@gmail.com" nam_last="Paull" nam_first="Stephanie" nam_mid_init="L" res_adr_street_1="173 Abbott street" res_adr_city="Springfield" res_adr_state="MA" res_adr_zip_code="01118" mail_adr_street_1="173 Abbott street" mail_adr_city="Springfield" mail_adr_state="MA" mail_adr_zip_code="01118" amt_indv_prem="0" amt_indv_income="0.00" amt_income_fpl="3293.34" pct_income_fpl="166.19" ind_pregnancy=" " cde_tpl_status="S" cde_born_to_st_empl=" "/>
<ns4:case num_case="00938195C" cde_case_status="1" hoh_nam_first="Stephanie" hoh_nam_last="Paull" hoh_nam_init="L" amt_family_prem="0" amt_family_mh_prem="12.00" amt_family_prem_assist="0"/>
<ns4:eligibility dte_begin_elig="2015-10-12" dte_end_elig="2016-09-06" cde_line="00" cde_elig_status="4" cde_cat="40" amt_gross_income="2470" family_size="4" dte_appl="2015-10-22" cde_region="58" cde_office="555" cde_close_reason="M1"/>
<ns4:eligibility dte_begin_elig="2016-08-13" cde_line="00" cde_elig_status="1" cde_cat="AP" amt_gross_income="3293.34" family_size="4" dte_appl="2015-10-22" cde_region="58" cde_office="555" cde_open_reason="01"/>
<ns4:uncompdeductible amt_uncmp_deductible="993" dte_effective="2016-08-13"/>
</ns4:EligibilityRequest>;
有2个标签。我想删除一个存在cde_close_reason的标记。请指教
答案 0 :(得分:0)
这有用吗?
SQL> with MY_TABLE as
2 (
3 select XMLTYPE(
4 '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5 <ns4:EligibilityRequest xmlns:ns5="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/eligresponse" xmlns:ns1="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/mmiscommon" xmlns:ns4="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/eligrequest" xmlns:ns3="http://xmlns.eohhs.ma.gov/newMMIS/ws/2006/05/MemberInfo">
6 <ns4:transactionsource id_medicaid="100027128782" id_other="00001740934" id_source="HIX"/>
7 <ns4:demographic dte_birth="1986-10-24" cde_sex="F" num_primary_ssn="031725754" cde_citizen="C" cde_race="UNKNOW" cde_ethnicity="UNKNOW" cde_homeless="N" cde_primary_lang="ENG" cde_lang_written="ENG" num_phone_day="4135376954" email="slpaullrn@gmail.com" nam_last="Paull" nam_first="Stephanie" nam_mid_init="L" res_adr_street_1="173 Abbott street" res_adr_city="Springfield" res_adr_state="MA" res_adr_zip_code="01118" mail_adr_street_1="173 Abbott street" mail_adr_city="Springfield" mail_adr_state="MA" mail_adr_zip_code="01118" amt_indv_prem="0" amt_indv_income="0.00" amt_income_fpl="3293.34" pct_income_fpl="166.19" ind_pregnancy=" " cde_tpl_status="S" cde_born_to_st_empl=" "/>
8 <ns4:case num_case="00938195C" cde_case_status="1" hoh_nam_first="Stephanie" hoh_nam_last="Paull" hoh_nam_init="L" amt_family_prem="0" amt_family_mh_prem="12.00" amt_family_prem_assist="0"/>
9 <ns4:eligibility dte_begin_elig="2015-10-12" dte_end_elig="2016-09-06" cde_line="00" cde_elig_status="4" cde_cat="40" amt_gross_income="2470" family_size="4" dte_appl="2015-10-22" cde_region="58" cde_office="555" cde_close_reason="M1"/>
10 <ns4:eligibility dte_begin_elig="2016-08-13" cde_line="00" cde_elig_status="1" cde_cat="AP" amt_gross_income="3293.34" family_size="4" dte_appl="2015-10-22" cde_region="58" cde_office="555" cde_open_reason="01"/>
11 <ns4:uncompdeductible amt_uncmp_deductible="993" dte_effective="2016-08-13"/>
12 </ns4:EligibilityRequest>') as XMLDOC
13 from dual
14 )
15 select XMLQUERY(
16 'declare namespace ns = "http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/eligrequest"; (: :)
17 copy $NEWXML := $XML
18 modify(
19 delete nodes $NEWXML/ns:EligibilityRequest/ns:eligibility[@cde_close_reason]
20 )
21 return $NEWXML'
22 passing XMLDOC as "XML"
23 returning content
24 ) RESULT
25 from MY_TABLE
26 /
RESULT
-----------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="WINDOWS-1252" standalone='yes'?>
<ns4:EligibilityRequest xmlns:ns5="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/eligresponse" xmlns:ns1="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/mmiscommon" xmlns:ns4="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/eligrequest" xmlns:ns3="http://xmlns.eohhs.ma.gov/newMMIS/ws/2006/05/MemberInfo">
<ns4:transactionsource id_medicaid="100027128782" id_other="00001740934" id_source="HIX"/>
<ns4:demographic dte_birth="1986-10-24" cde_sex="F" num_primary_ssn="031725754" cde_citizen="C" cde_race="UNKNOW" cde_ethnicity="UNKNOW" cde_homeless="N" cde_primary_lang="ENG" cde_lang_written="ENG" num_phone_day="4135376954" email="slpaullrn@gmail.com" nam_last="Paull" nam_first="Stephanie" nam_mid_init="L" res_adr_street_1="173 Abbott street" res_adr_city="Springfield" res_adr_state="MA" res_adr_zip_code="01118" mail_adr_street_1="173 Abbott street" mail_adr_city="Springfield" mail_adr_state="MA" mail_adr_zip_code="01118" amt_indv_prem="0" amt_indv_income="0.00" amt_income_fpl="3293.34" pct_income_fpl="166.19" ind_pregnancy=" " cde_tpl_status="S" cde_born_to_st_empl=" "/>
<ns4:case num_case="00938195C" cde_case_status="1" hoh_nam_first="Stephanie" hoh_nam_last="Paull" hoh_nam_init="L" amt_family_prem="0" amt_family_mh_prem="12.00" amt_family_prem_assist="0"/>
<ns4:eligibility dte_begin_elig="2016-08-13" cde_line="00" cde_elig_status="1" cde_cat="AP" amt_gross_income="3293.34" family_size="4" dte_appl="2015-10-22" cde_region="58" cde_office="555" cde_open_reason="01"/>
<ns4:uncompdeductible amt_uncmp_deductible="993" dte_effective="2016-08-13"/>
</ns4:EligibilityRequest>
SQL>