<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi Samuel,<br>
      <br>
      On 01/03/2015 19:56, Samuel Gougeon wrote:<br>
    </div>
    <blockquote cite="mid:54F360FA.9000404@free.fr" type="cite">
      <meta http-equiv="content-type" content="text/html;
        charset=windows-1252">
      <font face="Arial">Hello,<br>
        <br>
        Despite many trials, i am failing extracting the value of an
        attribute with  xmlXPath(). <br>
        Here is an example:<br>
      </font><tt><br>
        text = ["<</tt><tt>main>"</tt><tt><br>
                "    <itag  target=""valueA""  url=""valueB"" />"<br>
      </tt><tt><tt>        "    <itag  target=""valueA2""
          url=""valueB2"" />"<br>
        </tt></tt><tt><tt><tt>        "    <itag  target=""valueA3""
            url=""valueB3"" />"<br>
                    "</main>"<br>
                    ];<br>
            doc = xmlReadStr(text)<br>
            <br>
          </tt></tt></tt><font face="Arial">Now, we want to select all </font><tt><itag</tt><font
        face="Arial"> entries for which the </font><tt>target</tt><font
        face="Arial"> attribute has a given value (say </font><tt>valueA2</tt><font
        face="Arial">), and for them, get the related </font><tt>url</tt><font
        face="Arial"> value:<br>
        <br>
      </font><tt>-->e = xmlXPath(doc,
        "//itag[@target=""valueA2""]")   </tt><tt>// works:<br>
      </tt><tt> e  =</tt><tt><br>
      </tt><tt>XML List</tt><tt><br>
      </tt><tt>size: </tt><tt>1</tt><tt><br>
      </tt><tt><br>
      </tt></blockquote>
    <br>
    you got a list with one element<br>
    <br>
    <blockquote cite="mid:54F360FA.9000404@free.fr" type="cite"><tt> </tt><font
        face="Arial">but </font><tt>e</tt><font face="Arial"> has no
        attributes fields. So i cannot get its </font><tt>url </tt><font
        face="Arial">contents:<br>
      </font><tt>-->e.</tt><tt>name</tt><tt><br>
      </tt><tt> ans  = </tt><tt><br>
      </tt><tt> itag   </tt><tt><br>
      </tt></blockquote>
    <br>
    e(1).name<br>
    <br>
    fyi e.name is a shortcut to get all the nodes name in the list.<br>
    <br>
    <blockquote cite="mid:54F360FA.9000404@free.fr" type="cite"><tt> </tt><tt><br>
      </tt><tt>-->e.attributes</tt><tt><br>
      </tt><tt>    !--error 999 </tt><tt><br>
      </tt><tt>%XMLSet_e: Unknown field: attributes</tt><tt><br>
      </tt><tt><br>
      </tt></blockquote>
    <br>
    e(1).attributes<br>
    <br>
    <blockquote cite="mid:54F360FA.9000404@free.fr" type="cite"><tt> </tt><font
        face="Arial">How is it possible to do what we expect, whether it
        is?<br>
        Reading examples on the official xmlXPath webpage did not
        help...<br>
        <br>
        Thanks for any hints<br>
        Samuel<br>
        <br>
      </font></blockquote>
    <br>
    Best regards<br>
    <br>
    Calixte<br>
    <br>
    <blockquote cite="mid:54F360FA.9000404@free.fr" type="cite"><font
        face="Arial"> </font> <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Calixte Denizet
Software Development Engineer
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
<a class="moz-txt-link-freetext" href="http://www.scilab-enterprises.com">http://www.scilab-enterprises.com</a></pre>
  </body>
</html>