Selecting elements by name with namespaces

Task

Source document

<document xmlns="http://example.org">
  <item_0001>Erstes Element</item_0001>
  <item_0002>Zweites Element</item_0002>
  <item_0003>Drittes Element</item_0003>
  <item_0004 xmlns="http://example.net/">Viertes Element</item_0004>
  <other_0001>Erstes Element</other_0001>
  <other_0002>Zweites Element</other_0002>
</document>

Challenge

Select all elements having a name beginning with “item” and a namespace attached to “http://example.org”. For the expression, the prefix t is attached to the namespace “http://example.org”.

Desired selection (XML-output)

  • <item_0001 xmlns="http://example.org">Erstes Element</item_0001>
  • <item_0002 xmlns="http://example.org">Zweites Element</item_0002>
  • <item_0003 xmlns="http://example.org">Drittes Element</item_0003>

Available prefix for the XPath-expression

prefixNamespace
thttp://example.org

Exercise

Your input

Eine Lösung wäre: Lösung