Absolute locations and attributes in xmerl_xpath.

Enrique Marcote Peña mpquique@REDACTED
Mon Mar 8 12:35:13 CET 2004


Hi,

I've been trying... but I can't figure it out myself.  Could anyone send me an 
example on how to use absolute paths with xmerl_xpath?  In a previous post I 
saw the solution was

    "to have XPATH wrap the XML structure returned by
     xmerl_scan with an #xmerlDocument{} (or similar) record."

But don't know how to do it.  Here's the sample

XPath expression: "/AAA"

XML document:

<?xml version="1.0"?>
<AAA>
  <BBB/>
  <CCC/>
  <BBB/>
  <BBB/>
  <DDD>
    <BBB/>
  </DDD>
  <CCC/>
</AAA>

I've tried to assign the value returned by xmerl_scan to the content field of 
a #xmlDocument{} record with no joy.  

    E = xmerl_scan:file(FileName, [{space, normalize}]),
    XmlDocument = % ???
    xmerl_xpath:string("/AAA", XmlDocument).

I always get an empty list. Could anyone give me a detailed example? (please 
excuse my clumsiness).

I'd also need a clue on attribute expressions.  I can't get'em to work either.

XPath expression: "BBB[@id=\'b1\']"

XML document:

<?xml version="1.0"?>
<AAA>
  <BBB id = "b1"/>
  <BBB name = " bbb "/>
  <BBB name = "bbb"/>
</AAA> 


Thanks in advance.  Regards,

-- 
Quique
http://www.des.udc.es/~mpquique/




More information about the erlang-questions mailing list