Xml mule中的xpath表达式问题
我有一个返回给我的xml负载Xml mule中的xpath表达式问题,xml,xpath,mule,esb,Xml,Xpath,Mule,Esb,我有一个返回给我的xml负载 <response><row><row _id="1" _uuid="CD07C40E-4943-44B0-BF5E-370DA2133E25" _position="1" _address="http://data.seattle.gov/resource/fire-911/1"><type> --T::00</type></row><row _id="111" _uuid
<response><row><row _id="1" _uuid="CD07C40E-4943-44B0-BF5E-370DA2133E25" _position="1"
_address="http://data.seattle.gov/resource/fire-911/1"><type> --T::00</type></row><row _id="111"
_uuid="2423EC44-56D5-494C-941F-6F3B5DF49AC5" _position="111"
_address="http://data.seattle.gov/resource/fire-911/111"><address>10049 College Way N</address>
<type>Aid Response</type><latitude>47.701756</latitude><longitude>-122.335022</longitude>
<report_location latitude="47.701756" longitude="-122.335022"/>
<incident_number>F110104009</incident_number></row>
如果我通过一个在线测试人员插入这个xpath,它可以工作://response/row/row
我要怎么做才能让它在骡子里工作
My configuration.xml:
<flow name="seattleemergencyFlow1" doc:name="seattleemergencyFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8900"
path="get-emergency" doc:name="HTTP"/>
<http:outbound-endpoint exchange-pattern="request-response" host="data.seattle.gov" port="80"
path="resource/kzjm-xkqj.xml?" method="GET" contentType="application/json" doc:name="HTTP"/>
<object-to-string-transformer doc:name="Object to String"/>
<logger message="#[xpath://response/row/row]" level="ERROR" doc:name="Logger"/>
谢谢大家! 因为您使用的是Mule>=3.3.x,所以应该使用MEL而不是旧的xpath:expression计算器 对于MEL: 如果要获取org.dom4j.Element的java.util.List,请使用:
#[xpath('//response/row/row')[0].asXML()]
如果只需要第一个org.dom4j.Element,请使用:
#[xpath('//response/row/row')[0].asXML()]
如果要获取此元素的java.lang.String表示形式,请使用:
#[xpath('//response/row/row')[0].asXML()]
提示:在代码块前放四个空格以启用语法高亮显示。我试图编辑您的问题,但您回复了。您使用的是什么Mule版本?您好,大卫,我相信最新版本:Anypoint Studio-Mule ESB工具Anypoint Studio 2014年7月发布版本Id:201407311443我仍在研究此问题。我注意到您提供的XML示例是无效的:它在结尾处缺少有效性。这是一个复制/粘贴问题,还是您实际上正在处理损坏的XML输入是的,发生这种情况IRL:
#[xpath('//response/row/row')[0]]
#[xpath('//response/row/row')[0].asXML()]