473,668 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Specifying the Default Namespace

JT
Hi all,
I have a pretty basic question... I have a method (below) which uses
ExecuteXMLReade r to load the output from a FOR XML Explicit stored procedure
into an XML document, and then save the document to a file. It works well.
Now, I am trying to add namespace support, and want my namespace to be
something like "http://MapTo837P". How do I get this incorporated into the
XML document?
Thanks.
With sqlCmdSendClaim s
.Parameters("@N PID").Value = NPIDCursor

Dim doc As New XmlDocument
cnSA.Open()
Dim myXmlReader As XmlTextReader = .ExecuteXmlRead er()
myXmlReader.Whi tespaceHandling = WhitespaceHandl ing.None
doc.Load(myXmlR eader)
'close the XmlReader when finished.
myXmlReader.Clo se()
cnSA.Close()
doc.Save("D:\BT S\" & strFileLoc & "claim in\" & NPIDCursor & ".xml")

End With
--
John
Nov 12 '05 #1
3 3477
Hi John,

Thanks for your posting.
AS for the adding namespace for XmlDocument question you mentioned, what
namespace do you means, the default namespace for the xml document's root
element or any arbitary namespace for certain nodes in the document(with or
without prefix).

The .net's XmlDocument didn't provide buildin interfaces for adding
namespaces for all the elemetns in document(includ ing namespace prefix). If
you just want to add a default namespace for the whole XmlDocument, we can
use the XmlAttributes collection to append such as namespace, like:
============
XmlDocument doc = new XmlDocument();
doc.Load(@"..\. .\xpath.xml");

XmlAttribute attr = doc.CreateAttri bute("xmlns");
attr.Value = "http://www.test.org";

doc.DocumentEle ment.Attributes .Append(attr);
doc.Save("myout put.xml");
==============

If there are many namespaces you need to add, and some of them are under
sub nodes(under different hierarchy in the document) and also need to add
namespace prefix for node, I suggest you use XSLT to transform the Document
rather than use the DOM api to modify the XmlDocument.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 12 '05 #2
JT
Thanks Steve. I do mean the default namespace. I am doing the transform in
BizTalk Server 2004, and just trying to improve the interface between it and
my SQL Server datasource.
JT

"Steven Cheng[MSFT]" wrote:
Hi John,

Thanks for your posting.
AS for the adding namespace for XmlDocument question you mentioned, what
namespace do you means, the default namespace for the xml document's root
element or any arbitary namespace for certain nodes in the document(with or
without prefix).

The .net's XmlDocument didn't provide buildin interfaces for adding
namespaces for all the elemetns in document(includ ing namespace prefix). If
you just want to add a default namespace for the whole XmlDocument, we can
use the XmlAttributes collection to append such as namespace, like:
============
XmlDocument doc = new XmlDocument();
doc.Load(@"..\. .\xpath.xml");

XmlAttribute attr = doc.CreateAttri bute("xmlns");
attr.Value = "http://www.test.org";

doc.DocumentEle ment.Attributes .Append(attr);
doc.Save("myout put.xml");
==============

If there are many namespaces you need to add, and some of them are under
sub nodes(under different hierarchy in the document) and also need to add
namespace prefix for node, I suggest you use XSLT to transform the Document
rather than use the DOM api to modify the XmlDocument.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 12 '05 #3
Thanks for your followup.

If so, I think using the XmlNode's Attributes collection to manually set
the default namespace is a possbile approach. Have you met any further
problems ? If so, please feel free to post here.

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
10038
by: Mike Dickens | last post by:
hi, i'm sure this has come up before but havn't managed to find an answer. if i have the following xslt <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet method="xml" version="1.0" xmlns:ns1="abc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" media-type="text/xml" standalone="yes" version="1.0"/> <xsl:template match="/">
10
3247
by: Amittai Aviram | last post by:
This XHTML 1.0 Strict page -- http://www.studiolirico.org/docs/settimana2003.html has a bilingual title in Italian and English. The principle language of the page is Italian, so the <html> tag looks like this (w/o the space in the xmlns URL): <html xmlns="h ttp://www.w3.org/1999/xhtml" xml:lang="it" lang="it"> Within the body, I have English translations for all Italian text, and these are always contained within elements that bear the...
5
4071
by: Adam Child | last post by:
Hi All, I'm trying to validate an xml document. I'm having trouble setting the default namespace of the xml document. If I hard encode the namespace in the xml file then everything works fine. But I can't do this because it breaks our old tools which validate the xml to a dtd (error saying the dtd doens't allow xmlns attribute on the root element). So I'm trying to add the default namespace to the xml file by code. As follows:
1
1026
by: Serve Laurijssen | last post by:
Is there a difference between the following cases? using namespace System::Drawing; Pen __gc *pen = new Pen(Color::Black); //******************************* using namespace System::Drawing;
1
2530
by: Scott J. Peterson, MCSD, MCPSB, MCT | last post by:
I'm trying to emulate passing the 'SERVER' parameter in an NSLOOKUP using the Dns namespace, but I don't see anywhere this can be set. For example, I may do this; IPHostEntry ipEntry = Dns.GetHostEntry(strServerIP); ....but I want to specify WHICH DNS server to resolve against, not just the default. From a command prompt I would do NSLOOKUP, then type SERVER
2
1363
by: UJ | last post by:
What's the general feeling on using the using keyword versus spelling the type out completely. For instance, do most people put a using in so they can just say MyNewType or do people not use a using and they specify the namespace/type like MyNameSpace.MyNewType Just curious. I'm leaning towards not using the using and specifying things because then I know for a fact it's my datatype not a system datatype.
12
8554
by: Plop69 | last post by:
need some help on following: xml file 1 <TEST xmlns="http://test" > <OK>mlkddflmkj</OK> </TEST>
2
1733
by: shumaker | last post by:
I'm confused about the default namespace setting in the project properties. Help has the following: "Default namespace Specifies the base namespace for all files in the project. For example, if you set the root namespace to Project1 and you have a Class1 outside of any namespace in your code, its namespace would be Project1.Class1. If you have a Class2 within a namespace Order in code, its namespace would be Project1.Order.Class2."
1
2261
by: Adam Eccleshall | last post by:
Hi, I'm trying to write a routine to extract results from a web service written in VS 2005 using XPath, however VS doesn't put a prefix on result namespaces by default, so in the output from a service such as <soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body>
0
8374
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8890
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8791
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8575
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8653
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7398
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2784
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1783
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.