Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using SelectionNamespaces to rewrite prefixes

Status
Not open for further replies.

jargo

Programmer
Mar 31, 2006
3
US
Hello, I would like to assign a prefix alias to a URI.
After having done that if I loop through a message node by node doing something like:
get_nodeName
get_firstChild
get_nodeType
get_nodeValue

When I get the value I would like to have it return the new prefix not the old. (the prefix alias is what I want).

I know there are allot of properties like resolveExternals and validate on parse. I have played around with setting few of these but, I always get back node names containing the original prefix, not the alias's I set using the SelectionNamespaces property. Any suggestions would be helpful. Thanks. -J
 
Correction:

"When I get the value I would like to have it return the new prefix not the old. (the prefix alias is what I want)."

I meant:

When I get the NODE NAME back I want to returned with the new prefix.

Thanks J
 
Post some code

Jon

"I don't regret this, but I both rue and lament it.
 
var dom = new ActiveXObject("MSXML2.DOMDocument.5.0");
dom.async= false;
dom.load("example.xml");
if (dom.parseError.errorCode!=0)
{
alert("can't load dom" + dom.parseError.reason);
exit;
}

ns = "xmlns:z='dom.setProperty("SelectionNamespaces", ns);

alert("Results from selectNodes:\n");
var oNodes = dom.selectNodes("//root[1]/*");
var mynode;
for (i=0; i<oNodes.length; i++)
{
oNode = oNodes.nextNode;
if (oNode != null)
{
alert("Node ("+i+"), <"+ oNode.nodeName + ">:\n\t" +
oNode.xml + " " + mynode);
}
}

function alert(str)
{
WScript.echo(str+"\n");
}





example.xml:

<?xml version="1.0"?>
<root>
<branch>branch</branch>
<a:root xmlns:a=" <a:branch>a-branch</a:branch>
<b:branch xmlns:b=" b-branch
</b:branch>
<b:tree xmlns:b=" b-tree
</b:tree>
</a:root>
</root>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top