[libxml-devel] String parsing
Charlie Savage
cfis at savagexi.com
Sat Aug 16 16:56:36 EDT 2008
Eric M. wrote:
> I'm not sure if I'm just doing something wrong or whatnot, but I
> cannot get any form of xpath searching to work on a parsed string.
> Specifically, here is what is happening:
>
> -> XML generated, sent out to server
> <- Server receives XML, sends out response
> -- response received, xml = XML::Parser.string(response.body).parse
> -- xml.find('/error') executed, result is nil;
>
> XML response, and value of xml, is formatted like so:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <error xmlns="http://some-url.com" serial-number="some-serial-number">
> <error-message>Error message here.</error-message>
> </error>
Because the error is in an xml namespace. See the rdocs for the XPath
module. Basically:
xml.find('/mynamespace:error', :mynamespace => 'http://some-url.com')
Charlie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://rubyforge.org/pipermail/libxml-devel/attachments/20080816/8522bdab/attachment.bin>
More information about the libxml-devel
mailing list