Possible duplicate:
Nokogiri / Xpath namespace query
Assume XML exists
<?xml version="1.0" encoding="utf-8"?> <SomeResponse xmlns="some_namespace"> <Timestamp>......</Timestamp> <Ack>Failure</Ack> <Errors> <ShortMessage>ShortMessage111.</ShortMessage> <LongMessage>LongMessage111.</LongMessage> <ErrorCode>1</ErrorCode> <SeverityCode>Warning</SeverityCode> </Errors> <Errors> <ShortMessage>ShortMessage222.</ShortMessage> <LongMessage>LongMessage222.</LongMessage> <ErrorCode>2</ErrorCode> <SeverityCode>Warning2</SeverityCode> </Errors> <Version>123</Version> <Build>122345abt_3423423</Build> </SomeResponse>
I try to find all errors and their long and short messages using Nokogiri.
I do:
doc = Nokogiri.XML(xml) errors = doc.xpath("//Errors") puts errors errors2 = doc.xpath("//Errors//ShortMessage") puts errors
and shows nothing.
What am I doing wrong?
source share