How can I get JDOM/XPath to ignore namespaces?

后端 未结 4 1626
轮回少年
轮回少年 2021-01-18 19:35

I need to process an XML DOM, preferably with JDOM, where I can do XPath search on nodes. I know the node names or paths, but I want to ignore namespaces completely<

4条回答
  •  长发绾君心
    2021-01-18 20:10

    You can use /*:foo (XPath 2.0 or higher) or /yournamespace:* as explained here.

    The first variant selects all nodes with the matching name, regardless of what namespace they belong to, including having no namespace. The latter selects all nodes belonging to a specific namespace, regardless of the node name.

提交回复
热议问题