473,473 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Namespace problems

Hi;

I am creating an XmlDocument (.net 2.0) and then saving it. I need the final
xml file to look as follows (SpreadsheetML schema - I have no control over
it):

<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ss="schemas-microsoft-com:office:spreadsheet">
<CustomDocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<WindwardReports dt:dt="string">Version: 4.0.12</WindwardReports>
</CustomDocumentProperties>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:WrapText="1" ss:Horizontal="Left" ss:Vertical="Bottom"/>
</Style>
</Styles>
...

To create a namespace (this is my best guess based on the docs & googling):
element.SetAttribute(prefix.length() == 0 ? "xmlns" : ("xmlns:" + prefix),
url);
nameMgr.AddNamespace(prefix, url);
// when I create XmlDocument I also call:
nameMgr = new System.Xml.XmlNamespaceManager(xmlDoc.get_NameTabl e());

But what I am getting is:
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ss="schemas-microsoft-com:office:spreadsheet">
<CustomDocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<WindwardReports dt="string" xmlns="">Version: 4.0.12</WindwardReports>
</CustomDocumentProperties>
<Styles xmlns="urn:schemas-microsoft-com:office:spreadsheet">
<Style ID="Default" Name="Normal" xmlns="">
<Alignment WrapText="1" Horizontal="Left" Vertical="Bottom" />
</Style>
</Styles>
...

What am I doing wrong?

--
thanks - dave
Nov 12 '05 #1
1 1074
Hello!

You usually don't have to care about the xmlns-Attributes. Just use the
correct methods wich allow you to specify a prefix, localName, namespace
and value for an attribute.

The XmlDocument will write the necessary xmlns:ss="schemas.." for you.
If you want, you may also drop the prefix and have one created
automatically (but it may not look nice to humans).

--
Pascal Schmitt
Nov 12 '05 #2

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

Similar topics

88
by: Tim Tyler | last post by:
PHP puts most of its functions into a big flat global namespace. That leads to short function names - but creates a namespace minefield for programmers. Lots of the functions are legacies from...
3
by: Tonguç Yumruk | last post by:
I'm trying to build a completely plug-in based system. One of my problems is importing a package dynamically. I'm trying to emulate the import command. The __import__() function or imp module...
20
by: Patrick Guio | last post by:
Dear all, I have some problem with insertion operator together with namespace. I have a header file foo.h containing declaration of classes, typedefs and insertion operators for the typedefs in...
5
by: Alexander Gnauck | last post by:
Hello, i have problems with the Namespaces and the .Net XML Parser My XML looks like this: <query xmlns="jabber:iq:roster"> <item jid="srlee@localhost" name="srlee"...
1
by: Phill. W | last post by:
Having changed a VB.Net(2003) DLL project, I'm getting Type Loading problems in other code that uses my DLL. In my source code, I have a Namespace Statement something like this: Namespace...
32
by: toolmaster | last post by:
Since many of the modern computer languages have built-in namespace features, I can't understand why not add this feature into standard C. I've heard many people complain of the lacking of...
7
by: zahy[dot]bnaya[At]gmail[dot]com | last post by:
Hi all, Since I am always confusing this, I want to know once and for all what is the right way of doing this. I've noticed that some programs use: std::cout<< "yadayada"<<endl;
30
by: Pep | last post by:
Is it best to include the code "using namespace std;" in the source or should each keyword in the std namespace be qualified by the namespace tag, such as std::cout << "using std namespace" <<...
3
by: sjt003 | last post by:
I have been developing web apps in Visual Studio 2003, but since the other developers in my office don't use Visual Studio, I may have to stop too unless there is an efficient way for them to...
3
by: mrstephengross | last post by:
Hi folks. I've got a weird situation--gcc doesn't like the folllowing code snippet, but I don't know if it's correct or not. Here's the situation: In the global namespace, I've got a operator<<...
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
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,...
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
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...

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.