Get rid of extra namespace

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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"
 
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.
 
Back
Top