472,119 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

Namespacemanager adding default namespace

Hi

I'm trying to read xml file with namespacemanager; it seems that it
adds up a namespace if there is none; How can avoid this?
so <ID>00589</ID> becomes
<Id xmlns=\"x-schema:#Schema1\">00589</Id>
Thanks

Vishy

Nov 12 '05 #1
4 4338
Vishy wrote:
I'm trying to read xml file with namespacemanager; it seems that it
adds up a namespace if there is none; How can avoid this?
so <ID>00589</ID> becomes
<Id xmlns=\"x-schema:#Schema1\">00589</Id>


Namespacemanager can't add namespace, it only helps resolving
namespaces. Provide more info about how do you read your XML.

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.xmllab.net
http://blog.tkachenko.com
Nov 12 '05 #2
Thanks for reply; my code goes like this
docMessage is input XML Document; it has 2 namespaces
docOut is output XML document

XmlNamespaceManager nsmanager = new
XmlNamespaceManager(docMessage.NameTable);
nsmanager.AddNamespace("ns1", "http://Authorisation.ContextSchema");
nsmanager.AddNamespace("ns0", "http://Authorisation.RequestSchema");
nsmanager.AddNamespace("", "http://Authorisation.ContextSchema");
XmlNode nodeContext =
docMessage.SelectSingleNode("//ns1:Context",nsmanager);
if (nodeContext != null)
{
docOut.InnerXml =
docMessage.SelectSingleNode("//ns1:Context",nsmanager).OuterXml;
//This is to remove namespace added by namespace manager
docOut.InnerXml = docOut.InnerXml.Replace("
xmlns=\"x-schema:#Schema1\"","");
}

Nov 12 '05 #3
Hello!
XmlNamespaceManager nsmanager = new
XmlNamespaceManager(docMessage.NameTable);
nsmanager.AddNamespace("ns1", "http://Authorisation.ContextSchema");
nsmanager.AddNamespace("ns0", "http://Authorisation.RequestSchema");
nsmanager.AddNamespace("", "http://Authorisation.ContextSchema");
XmlNode nodeContext =
docMessage.SelectSingleNode("//ns1:Context",nsmanager);
How does the Document loaded into docMessage look like?

if (nodeContext != null)
{
docOut.InnerXml =
docMessage.SelectSingleNode("//ns1:Context",nsmanager).OuterXml;
You select the node twice, better use the nodeContext object here:
docOut.InnerXml = nodeContext.OuterXml;


--
Pascal Schmitt
Nov 12 '05 #4
doesn't work either

Vishy

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by surrealtrauma | last post: by
34 posts views Thread by Adam Hartshorne | last post: by
reply views Thread by Martin | last post: by
5 posts views Thread by Water Cooler v2 | last post: by
1 post views Thread by Bruce Sandeman | last post: by
3 posts views Thread by =?Utf-8?B?QWxleGFuZGVyIFd5a2Vs?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.