c - Filtering XML with XPath based on content of child elements -


i need filter response of soap web-service. since soap based on xml, thinking using libxml2, not able understand how write xpath expression achieve desired result.

at end of message you'll find example of response, 2 notficationmessages sent, 1 has topic tns1:ruleengine/linedetector/crossed , other 1 has topic tns1:ruleengine/cellmotiondetector/motion .

i trying write following xpath expressions:

  • match notficationmessage topic tns1:ruleengine/linedetector/crossed
  • match notficationmessage topic tns1:ruleengine//.
  • match notficationmessage topic tns1:ruleengine//.

all examples found match on attributes, not content of child elements.

so i'm asking.

  1. are kinds of matching doable libxml2 or xpath in general?
  2. can please give me hint writing xpath expressions?
<?xml version="1.0" encoding="utf-8"?>   <soap-env:envelope      xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope"      xmlns:wsa="http://www.w3.org/2005/08/addressing"      xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"      xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"      xmlns:tet="http://www.onvif.org/ver10/events/wsdl"      xmlns:tns1="http://www.onvif.org/ver10/topics"     xmlns:tt="http://www.onvif.org/ver10/schema">     <soap-env:header>       <wsa:action>  http://www.onvif.org/ver10/events/wsdl/pullpointsubscription/pullmessagesresponse       </wsa:action>     </soap-env:header>     <soap-env:body>       <tet:pullmessagesresponse>         <tet:currenttime>           2008-10-10t12:24:58         </tet:currenttime>         <tet:terminationtime>           2008-10-10t12:25:58         </tet:terminationtime>         <wsnt:notificationmessage>           <wsnt:topic dialect="http://www.onvif.org/ver10/tev/topicexpression/concreteset">             tns1:ruleengine/linedetector/crossed           </wsnt:topic>           <wsnt:message>             <tt:message utctime="2008-10-10t12:24:57.321z">               <tt:source>                 <tt:simpleitem name="videosourceconfigurationtoken"                                value="1"/>                 <tt:simpleitem name="videoanalyticsconfigurationtoken"                                value="2"/>                 <tt:simpleitem value="myimportantfence1" name="rule"/>               </tt:source>               <tt:data>                 <tt:simpleitem name="objectid" value="15" />               </tt:data>             </tt:message>           </wsnt:message>         </wsnt:notificationmessage>         <wsnt:notficationmessage>           <wsnt:topic dialect="http://www.onvif.org/ver10/tev/topicexpression/concreteset">            tns1:ruleengine/cellmotiondetector/motion           </wsnt:topic>           <wsnt:message>             <tt:message utctime= "2010-10-20t12:24:57.628">               <tt:source>                <tt:simpleitem name="videosourceconfigurationtoken" value="1"/>                <tt:simpleitem name="videoanalyticsconfigurationtoken" value="1"/>                <tt:simpleitem name="rule" value="motionindefinedcells"/>               </tt:source>                 <tt:data>                <tt:simpleitem name="ismotion" value="true"/>               </tt:data>             </tt:message>           </wsnt:message>         </wsnt:notficationmessage>       </tet:pullmessagesresponse>     </soap-env:body> </soap-env:envelope> 

all need basic xpath expressions using location paths , predicates:

  1. match notficationmessage topic tns1:ruleengine/linedetector/crossed

    //wsnt:notificationmessage[wsnt:topic = 'tns1:ruleengine/linedetector/crossed'] 
  2. match notficationmessage topic tns1:ruleengine//.

    //wsnt:notificationmessage[wsnt:topic = 'tns1:ruleengine//.'] 
  3. match notficationmessage topic tns1:ruleengine//.

    //wsnt:notificationmessage[wsnt:topic != 'tns1:ruleengine//.'] 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -