473,554 Members | 3,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Namespacemanage r adding default namespace

Hi

I'm trying to read xml file with namespacemanage r; 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 4401
Vishy wrote:
I'm trying to read xml file with namespacemanage r; 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>


Namespacemanage r 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

XmlNamespaceMan ager nsmanager = new
XmlNamespaceMan ager(docMessage .NameTable);
nsmanager.AddNa mespace("ns1", "http://Authorisation.C ontextSchema");
nsmanager.AddNa mespace("ns0", "http://Authorisation.R equestSchema");
nsmanager.AddNa mespace("", "http://Authorisation.C ontextSchema");
XmlNode nodeContext =
docMessage.Sele ctSingleNode("//ns1:Context",ns manager);
if (nodeContext != null)
{
docOut.InnerXml =
docMessage.Sele ctSingleNode("//ns1:Context",ns manager).OuterX ml;
//This is to remove namespace added by namespace manager
docOut.InnerXml = docOut.InnerXml .Replace("
xmlns=\"x-schema:#Schema1 \"","");
}

Nov 12 '05 #3
Hello!
XmlNamespaceMan ager nsmanager = new
XmlNamespaceMan ager(docMessage .NameTable);
nsmanager.AddNa mespace("ns1", "http://Authorisation.C ontextSchema");
nsmanager.AddNa mespace("ns0", "http://Authorisation.R equestSchema");
nsmanager.AddNa mespace("", "http://Authorisation.C ontextSchema");
XmlNode nodeContext =
docMessage.Sele ctSingleNode("//ns1:Context",ns manager);
How does the Document loaded into docMessage look like?

if (nodeContext != null)
{
docOut.InnerXml =
docMessage.Sele ctSingleNode("//ns1:Context",ns manager).OuterX ml;
You select the node twice, better use the nodeContext object here:
docOut.InnerXml = nodeContext.Out erXml;


--
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
5911
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 of the class – the numerator and the denominator. Provide a constructor that enables an object of this class to be initialized when it is declared....
34
4132
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 "push_back" a copy of this into a vector V. This is repeated many times in an iterative process. Ok whenever I "push_back" a copy of Class A, I also want...
2
2522
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 I never fully understood why. I've now hit another problem. It might be code blindness but I can't see why it doesn't work. I am trying to select...
9
10870
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 the wheel, right? Everything so far is working well with the Active Directory. The problem I am having is with adding File Permissions to a...
0
1044
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 xpathexpression. Because I have a namespace in the xml, I have to use the xmlNameSpaceManager and comile an xpathquery as below:
0
1208
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 returned from selectsinglenode. I think I am not creating the namespace manager correctly. I have created a very small sample piece of code...
5
4580
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 to add a dictionary of name-value pairs. In other words, instead of a single name-value, I want to add a name-value collection in there. I could do...
1
5062
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) { xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); namespaceManager = new
3
1314
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 project would not recoginize any assembly which had been added to the project, even know they were all there, this happened to the designer.cs file that...
0
7583
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7507
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7783
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8019
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7542
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6127
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5424
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1115
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.