Java 使用JSTL解析包含命名空间的XML
我想使用JSTL解析web服务中的XML。XML包含导致解析和输出结果出现问题的名称空间 XML字符串:Java 使用JSTL解析包含命名空间的XML,java,xml,parsing,namespaces,jstl,Java,Xml,Parsing,Namespaces,Jstl,我想使用JSTL解析web服务中的XML。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
<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>
100000
15
98104
4.2
416
31
JSP文件(resultString包含XML):
${map.resultString}
...
删除XML中的paymentSummary部分时,输出正确为1000000。我需要能够解析包含名称空间的XML。请帮忙?我设法找到了一个适合我的解决方案
<b>MonthlyPayments > request > Price </b>:
<x:out select="$doc//*[name()='request']/*[name()='price']"/>
<br>
月付款>请求>价格:
月付款>请求>价格:100000
<b>MonthlyPayments > response > payment > rate </b>:
<x:out select="$doc//*[name()='response']/*[name()='payment']/*[name()='rate']"/>
<br>
月付款>响应>付款>费率:
月付款>响应>付款:4.2
<b>MonthlyPayments > response > payment > loantype </b>:
<x:out select="$doc//*[name()='response']/*[name()='payment']/@loanType"/>
MonthlyPayments>response>payment>loantype:
MonthlyPayments>response>payment>loantype:thirtyYearFixed在此处检查类似问题:
<b>MonthlyPayments > response > payment > loantype </b>:
<x:out select="$doc//*[name()='response']/*[name()='payment']/@loanType"/>