Xpath doesn't return anything in Nokogiri

If you don't want to deal with namespaces, you can use

doc.remove_namespaces!

It is Lazy (= efficient), but it is not recommended.


Your XML is in the namespace some_namespace but your XPaths don't have a namespace binding. You're essentially querying different elements than are in your XML.

Using "Clark notation", the element you're trying to get to is

{some_namespace}ShortMessage

but you're querying for ShortMessage in the no-namespace.

Just because there is no prefix, i.e. the namespace is the default namespace, doesn't mean you can ignore it.

Tags:

Xml

Ruby

Nokogiri