473,396 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 4387
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: surrealtrauma | last post by:
the requirement is : Create a class called Rational (rational.h) for performing arithmetic with fractions. Write a program to test your class. Use Integer variables to represent the private data...
34
by: Adam Hartshorne | last post by:
Hi All, I have the following problem, and I would be extremely grateful if somebody would be kind enough to suggest an efficient solution to it. I create an instance of a Class A, and...
2
by: Chris | last post by:
Hi, I'm trying to extract data from objects that contain xml that fits a third party schema with it's own root namespace. I've added a namespace manager that seemed to work most of the time but...
9
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
0
by: LockyBoy | last post by:
Hi Have created an xml document with an xmltextwriter with a namespace, so it can be validated against an xsd schema. Later in my application, I want to extract values from the xml and am using...
0
by: Martin | last post by:
Hi, I am using xmldocument.selectsinglenode to query an xml document. This works perfectly when the document to be queried has no namespace, however as some as i put a namespace in then null is...
5
by: Water Cooler v2 | last post by:
I know that we can add a single name value entry in app.config or web.config in the configuration/configSettings/appSettings section like so: <add key="key" value="value" /> Question: I want...
1
by: Bruce Sandeman | last post by:
Hi, Is anyone able to help me? I have the following code and when I try to create an XPathNavigator object it keeps returning null. any cunning ideas? private void loadXMLDoc(String xml) {...
3
by: =?Utf-8?B?QWxleGFuZGVyIFd5a2Vs?= | last post by:
I recently raninto major problems when I added the Exception namespace to the Project which has my DBML file attached to it. Once I renamed all the Exceptions instances to Syste.Exception the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.