1
我想使用JSTL解析來自Web服務的XML。 XML包含導致具有分析問題的命名空間,並輸出結果使用JSTL解析包含名稱空間的XML
XML字符串:
<MonthlyPayments:paymentsSummary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:MonthlyPayments="http://www.zillow.com/static/xsd/MonthlyPayments.xsd" xsi:schemaLocation="http://www.zillow.com/static/xsd/MonthlyPayments.xsd http://www.zillowstatic.com/vstatic/LATEST/static/xsd/MonthlyPayments.xsd">
<request>
<price>100000</price>
<down>15</down>
<zip>98104</zip>
</request>
<payment loanType="thirtyYearFixed">
<rate>4.2</rate>
<monthlyPrincipalAndInterest>416</monthlyPrincipalAndInterest>
<monthlyMortgageInsurance>31</monthlyMortgageInsurance>
</payment>
</MonthlyPayments:paymentsSummary>
JSP文件(resultString包含XML):
<c:set var="xmldocument">${map.resultString}</c:set>
<x:parse var="doc" xml="${xmldocument}" />
...
<x:out select="$doc/MonthlyPayments/request/price" />
在拆除中的paymentSummary部分XML的輸出是正確的1000000.我需要能夠解析包含命名空間的XML。請幫忙?
檢查類似的問題這裏:http://stackoverflow.com/questions/17580051/accessing-imported-xml-element-attri弼與-A-給定名稱空間中-A-JSP – Prasad