Pages: 1
Print
Author Topic: Deafult namespace and getnodesbyXPath  (Read 3016 times)
achu
Member

Posts: 43


« on: April 15, 2010, 10:46:43 AM »

The xml document I have is referenced to xml schema. it has default namespace  xmlns="http://data.mydomain.com/schema".
when I use getNodesbyXPath, I can not get the results back without giving the prefix, which is from the default namespace.
for example, I get nothing when xpath expression is specified like *//P[1]. Unless xpath is added with prefix, such as *//schema:P[1], the results are returned as expected.

However, this is not the case for getElementsbyTagName.

is getNodesbyXPath is namesapce sensitive? even with the default namespace?


XMetaL 5.5
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: April 15, 2010, 02:50:17 PM »

For getNodesByXPath to find a particular node you will need to include the prefix for that node, yes. The default namespace is not assumed (or not automatically inserted into your XPath if you want to think of it that way, or perhaps alternatively -- the API doesn't try to hunt around everywhere checking element names then walk back up the node tree to see if a particular node should have a particular prefix pre-pended because that would be far too expensive and slow).

You might think of the XML node tree (in memory) as having the prefix hard-coded (really not the best term) into each node's name, and so what you see in TagsOn view is about the best representation of the tree that you can get.
Logged
Pages: 1
Print
Jump to: