如何在javascript中读取包含xml的字符串的节点值?

时间:2011-10-04 13:07:43

标签: javascript xml

我的页面中有一个字符串,字符串响应。  此String包含xml内容。现在我需要根据响应值检查条件。所以我需要获取特定的节点值。例如,

<?xml version="1.0" encoding="UTF-8"?>
<Response version="1.0">   
    <Transaction mode="INTEGRATOR_TEST" channel="d225a9fefe3fbaf400fe43294aca000d" response="SYNC">                <Identification>
               <ShortID>463.4646.464.4463</ShortID>  
               <UniqueID>8a82944932c9db190132cee846be54d0</UniqueID>  
               <TransactionID>K8463</TransactionID>   
    </Identification>  
    <Payment> 
               <Clearing>   
                   <Amount>1000.00</Amount>      
                   <Currency>INR</Currency>  
                   <Descriptor>XX XCXXXXX</Descriptor> 
                   <FxRate>1.0</FxRate>    
                   <FxSource>INTERN</FxSource>  
                   <FxDate>2011-10-04 12:28:41</FxDate>   
               </Clearing>       
    </Payment>  
    <Processing code="DD.DB.90.00">  
              <Timestamp>2011-10-04 12:28:41</Timestamp>     
              <Result>ACK</Result>     
              <Status code="90">NEW</Status>  
              <Reason code="00">Successful Processing</Reason>     
              <Return code="000.100.110">Request successfully processed in 'Merchant in Integrator Test Mode'</Return>          <Risk score="0" />      
    </Processing>  
    </Transaction>
</Response>

那么如何读取特定节点?例如,如何读取状态节点?...

1 个答案:

答案 0 :(得分:0)

使用XML Dom对象。

此处示例:

http://www.w3schools.com/xml/xml_dom.asp