[xml] reading xml subtree (getting xml fragment )



Hi

 

I have an xml document  like this :

 

<?xml version="1.0" encoding="utf-8"?>

<config>

    <triggers>

    <trigger id="1" enabled="1">

      <inputtype>42</inputtype>

      <inputaddr>42</inputaddr>

       <email enabled="1">

        <toname>Nancy</toname>

        <toaddr>sagaert johan skynet be</toaddr>

      </email>

      <sms enabled="1">

        <tonumber>32479504265</tonumber>

        <messsage>test.</messsage>

      </sms>

    </trigger>

     <trigger id="2" enabled="1">

       <inputtype>42</inputtype>

      <inputaddr>40</inputaddr>

      <inputlevel>255</inputlevel>

      <method>==</method>

      <mininterval>60</mininterval>

      <minvalid>10</minvalid>

      <email enabled="1">

        <toname>Swammy</toname>

        <toaddr>sagaert johan skynet be</toaddr>

        <subject>Alarm van zaventem</subject>

        <body>Het light is aan</body>

      </email>

      <sms enabled="1">

        <tonumber>32479504265</tonumber>

        <messsage>Den drank is weeral op</messsage>

      </sms>

    </trigger>

 </triggers>

</config>

 

II use xpath to retrieve the trigger node with id =1

So far no problem, ,how can I get the innerxml of the node I have found from my xmlnodeptr ?

I want this (xml fragment ) as result :

 

  <trigger id="1" enabled="1">

      <inputtype>42</inputtype>

      <inputaddr>42</inputaddr>

       <email enabled="1">

        <toname>Nancy</toname>

        <toaddr>sagaert johan skynet be</toaddr>

      </email>

      <sms enabled="1">

        <tonumber>32479504265</tonumber>

        <messsage>test.</messsage>

      </sms>

    </trigger>

 

How can I get this result ?

I would send this string as output of a cgi program and parse the fragment in the web browser with jquery instead of having to send the whole (large) document and having to do the search on the browser side.

This seemed trivial at first but I’am stuck now since there is no getinnerxml function. (xmlNodeGetContent does not give me the result i want).

 

 

Any hints or alternatives ?

 

Thanks in advance.

 

Sagaert Johan

 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]