473,506 Members | 17,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get rid of extra namespace

I've the following code:

writer.WriteStartDocument();
writer.WriteStartElement("n", "Property", "http://www.aaa.com");
writer.WriteAttributeString("xmlns", "j", null, "http://www.bbb.com");

writer.WriteAttributeString("xmlns", "n", null, "http://www.aaa.com");

writer.WriteElementString("PropertyDescriptionText ", "http://www.bbb.com",
"hello");

string prefix = writer.LookupPrefix("http://www.aaa.com");
string prefix2 = writer.LookupPrefix("http://www.bbb.com");

writer.WriteElementString("PropertyUNCode", "http://www.aaa.com", "1234");
writer.WriteStartElement(prefix2, "PropertyStatus", "http://www.bbb.com");
writer.WriteElementString("StatusText", "http://www.bbb.com", "FOUND");
writer.WriteEndElement();
....

I got the following output

<n:Property xmlns:n="http://www.aaa.org">
<j:PropertyDescriptionText
xmlns:j="http://www.bbb.com">Hello</j:PropertyDescriptionText>
<n:PropertyUNCode>1234</n:PropertyUNCode>
<j:PropertyStatus xmlns:j="http://www.bbb.com">
<j:StatusText>FOUND</j:StatusText>
</j:PropertyStatus>

Instead i want the output to be

<n:Property xmlns:n="http://www.aaa.com" xmlns:j="http://www.bbb.com">
<j:PropertyDescriptionText>Hello</j:PropertyDescriptionText>
<n:PropertyUNCode>1234</n:PropertyUNCode>
<j:PropertyStatus>
<j:StatusText>FOUND</j:StatusText>
</j:PropertyStatus>

where xmlns:j is the attribute of the root node and get rid of subsequence
display of the namespace in element that refering to "http:www.bbb.com"

Jul 21 '05 #1
1 1013
you may want to post this question to
Microsoft.Public.DotNet.XML

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Willie" <Wi****@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
I've the following code:

writer.WriteStartDocument();
writer.WriteStartElement("n", "Property", "http://www.aaa.com");
writer.WriteAttributeString("xmlns", "j", null, "http://www.bbb.com");

writer.WriteAttributeString("xmlns", "n", null, "http://www.aaa.com");

writer.WriteElementString("PropertyDescriptionText ", "http://www.bbb.com",
"hello");

string prefix = writer.LookupPrefix("http://www.aaa.com");
string prefix2 = writer.LookupPrefix("http://www.bbb.com");

writer.WriteElementString("PropertyUNCode", "http://www.aaa.com", "1234");
writer.WriteStartElement(prefix2, "PropertyStatus", "http://www.bbb.com");
writer.WriteElementString("StatusText", "http://www.bbb.com", "FOUND");
writer.WriteEndElement();
...

I got the following output

<n:Property xmlns:n="http://www.aaa.org">
<j:PropertyDescriptionText
xmlns:j="http://www.bbb.com">Hello</j:PropertyDescriptionText>
<n:PropertyUNCode>1234</n:PropertyUNCode>
<j:PropertyStatus xmlns:j="http://www.bbb.com">
<j:StatusText>FOUND</j:StatusText>
</j:PropertyStatus>

Instead i want the output to be

<n:Property xmlns:n="http://www.aaa.com" xmlns:j="http://www.bbb.com">
<j:PropertyDescriptionText>Hello</j:PropertyDescriptionText>
<n:PropertyUNCode>1234</n:PropertyUNCode>
<j:PropertyStatus>
<j:StatusText>FOUND</j:StatusText>
</j:PropertyStatus>

where xmlns:j is the attribute of the root node and get rid of subsequence
display of the namespace in element that refering to "http:www.bbb.com"

Jul 21 '05 #2

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

Similar topics

1
4120
by: Chris Bedford | last post by:
Hi: this question has been driving me crazy. would be grateful for any help. I am writing a version of the identity transformation to filter some documents (they happen to be wsdl docs)....
8
2279
by: Some Clown | last post by:
Well... after much consultation with folks on this group, I was convinced that using char arrays and such was bad. I had no clue due in no small part to me being a complete newbie, and the fact...
0
1352
by: IMS.Rushikesh | last post by:
Hi All, I want to serialize an object which contain the DataTable. As DataSet is MarshalByRef object and is serializable. I am using it directly. Even my data is also serialize and save it to...
2
1792
by: matthew.schneider | last post by:
I have a defined XML Schema, and XML documents containing data that I validate against it. Periodically, I will have a data document that will contain extra elements that are not part of my schema....
5
1509
by: voidfill3d | last post by:
I have a problem with ASP.NET and entering data into a MS SQL database. I have the following code and what happens is the data gets into the database, but with one extra space at the end of ...
2
1399
by: Siegfried Heintze | last post by:
I'm running on g++ v2.95 and 3.2. Why is it that the print functions work fine without any extra template parameters, but the SizeOfCod2 function requires that the bold code be uncommented? ...
2
2432
by: ricky | last post by:
Can anybody help with the function to get rid of extra characters in the file. I want to remove the string from the file.So i read from input file and pass the string say "john" if found dnt write...
4
1789
by: VK | last post by:
Can well-formed but non-validated XHTML have extra namespaces? Say <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />...
1
2808
by: Paul J. Lucas | last post by:
I have code that builds a DOM using the Java org.w3c.dom API and it adds an extra attribute to one of the elements that I don't want. Not only that, the value it adds is wrong. The code to...
11
1983
by: Trent | last post by:
Running this I see that on first run, both bubble and selection sort have 9 sort counts while insertion sort has ZERO. With a sorted list, should this be ZERO for all? Also bsort and Ssort have...
0
7220
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
7105
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
7308
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
7371
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...
0
5617
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
5037
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
4702
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
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1534
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 ...

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.