我有这段代码:
<Detail2 domID='1'>
<tax_amt>1</tax_amt>
<Taxes status="N"><Tax domID="1"><attribute pkNames="" selected="N" status="N" updateFlag="A"/><tran_code>BILS</tran_code><tran_id>@dbID</tran_id><line_no> 1</line_no><line_no__tax> 1</line_no__tax><tax_code>SRVC</tax_code><tax_class>1SAL</tax_class><tax_chap>8040</tax_chap><tax_base>AMT</tax_base><tax_env>SRVC08091</tax_env><tax_descr>SERVICE TAX</tax_descr><taxable_amt>36.0</taxable_amt><tax_perc protect="1">4.0</tax_perc><tax_amt>1</tax_amt><chg_stat>N</chg_stat><tax_set>SRVC890001</tax_set><effect>+</effect><acct_code__reco>3022 </acct_code__reco><cctr_code__reco>H101</cctr_code__reco><reco_perc>100.0</reco_perc><reco_amount>1.0</reco_amount><acct_code>3022 </acct_code><cctr_code>H101</cctr_code><rate_type>P</rate_type><round>R</round><round_to>1.0</round_to><tax_form/><tax_form_date/><posted>N</posted><pay_tax>N</pay_tax><cc_editopt>N</cc_editopt><series_edit/><curr_code__tax/><curr_code__tran/><tax_amt__tcurr>1</tax_amt__tcurr><exch_rate>1.0</exch_rate><exch_rate_tran>1.0</exch_rate_tran></Tax></Taxes>
</Detail2>
<Detail2 domID='1' ><tax_amt>1</tax_amt></Detail2></Root>
答案 0 :(得分:0)
您可以使用jquery吗?如果是,那么
$( "Detail2" ).find( "tax_amt" ).text();
或仅javascript然后
var doc = new DOMParser().parseFromString(xmlString,'text/xml');
var result = doc.evaluate('/Detail2/tax_amt', doc, null, XPathResult.STRING_TYPE, null);
alert(result)