General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Deafult namespace and getnodesbyXPath

  • achu

    Deafult namespace and getnodesbyXPath

    Participants 0
    Replies 1
    Last Activity 12 years, 7 months ago

    The xml document I have is referenced to xml schema. it has default namespace¬† xmlns=””.
    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


    Derek Read

    Reply to: Deafult namespace and getnodesbyXPath

    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.

Lost Your Password?