General XMetaL Discussion
achu April 15, 2010 at 4:46 pm
Deafult namespace and getnodesbyXPathApril 15, 2010 at 4:46 pmParticipants 0Replies 1Last Activity 12 years, 7 months ago
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. Unless xpath is added with prefix, such as *//schema:P, 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.5Derek Read April 15, 2010 at 8:50 pm
Reply to: Deafult namespace and getnodesbyXPathApril 15, 2010 at 8:50 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.
- You must be logged in to reply to this topic.