I have the following soap envelope.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetLatestSchedulesExResponse xmlns="http://www.ezitracker.com/
eziTrackerData/">
<GetLatestSchedulesExResult><ResultExDataset
xmlns="http://
www.ezitracker.net/eziTrackerData/ResultExDataset.xsd">
<ResultSummary>
</ResultSummary>
</ResultExDataset><SchedulesDataset xmlns="http://
www.ezitracker.net/eziTrackerData/SchedulesDataset.xsd" /></
GetLatestSchedulesExResult>
</GetLatestSchedulesExResponse>
</soap:Body>
</soap:Envelope>
I can't for the life of me get to any of the nodes that I want in this
document. I tried to follow the documentation and wrote the following
doc=get_xml_from_file(filename)
root=doc.root
faults = root.find_first( "//soap:Fault")
if faults != nil
puts "SOAP FAULT: "
p root.find("/soap:Envelope/soap:Body/soap:Fault/
faultstring").first.first
#this works!
else
puts "SUCCESS!"#
end
# I am trying to get this node...
#<GetLatestSchedulesExResponse xmlns="http://www.ezitracker.com/
eziTrackerData/"> <GetLatestSchedulesExResult>
register_namespace = doc.find('//ns:GetLatestSchedulesExResponse',
'ns:http://www.ezitracker.com/eziTrackerData/')
node = doc.find_first('/soap:Envelope/soap:Body/
ns0:GetLatestSchedulesExResponse')
this gives the error
Error: Undefined namespace prefix at :0.
xmlXPathEval: evaluation failed
/usr/lib/ruby/gems/1.8/gems/libxml-ruby-0.9.5/lib/libxml/document.rb:
55:in `find': Error: Undefined namespace prefix at :0.
(LibXML::XML::Error)
from /usr/lib/ruby/gems/1.8/gems/libxml-ruby-0.9.5/lib/libxml/
document.rb:55:in `find'
from /usr/lib/ruby/gems/1.8/gems/libxml-ruby-0.9.5/lib/libxml/
document.rb:62:in `find_first'
from /home/tim/junk/soap_test_xml.rb:165
I have tried all kinds of variations but I can't find anything that
works.
Where have I gone wrong?
_______________________________________________
libxml-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/libxml-devel