S
S
Shimpanze2017-08-04 08:14:06
XPath
Shimpanze, 2017-08-04 08:14:06

XPath: what does "namespace" axis mean?

Good afternoon!
Can you please explain what the "namespace" axis means?
The official documentation defines it as: Selects all nodes in the namespace of the current node .
Please explain what this means and give an example.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Fov, 2017-08-13
@Shimpanze

Namespaces are needed to resolve tag name conflicts in xml.
For example, organizations and their clients

<?xml version="1.0" encoding="UTF-8" ?>
<root xmlns:company="http://example.com/company" xmlns:customer="http://example.com/customer">
  <company:company>
    <company:name>ACME</company:name>
    <customer:name>Vasya</customer:name>
    <customer:name>Tom</customer:name>
  </company:company>
  <company:company>
    <company:name>Scrooge McDuck Inc</company:name>
    <customer:name>Mary</customer:name>
    <customer:name>Bob</customer:name>
    <customer:name>Rob</customer:name>
  </company:company>
</root>

All organizations:
All clients:
All clients of the organization:
All client organizations:
//company:company[customer:name = 'Vasya']/company:name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question