Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Need to remove blank XMLNS attribute from xmldocument

Reply
Thread Tools

Need to remove blank XMLNS attribute from xmldocument

 
 
=?Utf-8?B?RXdhbiBGYWlyd2VhdGhlcg==?=
Guest
Posts: n/a
 
      04-14-2006
Hi,

I'm generating the below XML in c# for an asp.net application

When i've generated this XML the <LaboratoryDetails xmlns=""> element has a
blank xmlns set. How do i either a) remove this attribute or b) prevent it
from happening in the first place.

To generate the xml I've got two template files which i've included at the
bottom of this post. Two xmldocuments are created in my code which load the
two sepearate templates as follows: -
XmlDocument doc = new XmlDocument();
XmlDocument lab = new XmlDocument();
doc.Load("TYPE3_GETLABS_RESPONSE_TEMPLATE.xml");
lab.Load("LabDetails_Template.xml");


The lab details are then generated as follows:
XmlNode node0 = lab.SelectSingleNode("//LaboratoryDetails/Name");
node0.InnerText = myReader["labname"].ToString();

where myReader is a SqlDataReader object.

The lab details are then entered into the doc XmlDocument as follows:
XmlDocumentFragment payloadInsert =
doc.CreateDocumentFragment();
payloadInsert.InnerXml = lab.InnerXml;

XmlNode node =
doc.SelectSingleNode("//payload:AvailableLaboratories", nsm);
node.InsertAfter(payloadInsert, node.LastChild);

So the question is how do i prevent this from setting the xmlns="" attribute?

Any help much appreciated - sample XMl document and templates below: -
==== XML Generated By App ===========

<TYPE3_GETLABS_RESPONSE xmlns="urnathology:labtolabPayload"
xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urnathology:labtolabPayload TYPE3_GETLABS_RESPONSE.xsd">
<InternalRouting>
<FromLab>
</FromLab>
<ToLab>
</ToLab>
</InternalRouting>
<AvailableLaboratories>
<LaboratoryDetails xmlns="">
<Name>Leeds</Name>
<LabCode>
</LabCode>
<Contact>
</Contact>
<Telephone>
</Telephone>
<Address1>
</Address1>
<Address2>
</Address2>
<Postcode>
</Postcode>
</LaboratoryDetails>
<LaboratoryDetails xmlns="">
<Name>Wake</Name>
<LabCode>Wake</LabCode>
<Contact>Ewan Fairweather</Contact>
<Telephone>01274 530438</Telephone>
<Address1>22 Wakefield Road</Address1>
<Address2>Wakefield</Address2>
<Postcode>WK3 4RF</Postcode>
</LaboratoryDetails>
</AvailableLaboratories>
</TYPE3_GETLABS_RESPONSE>
===End of XMl Generated By App =====


==Type3_GetLabsResponse Template ===
<TYPE3_GETLABS_RESPONSE xmlns="urnathology:labtolabPayload"
xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urnathology:labtolabPayload TYPE3_GETLABS_RESPONSE.xsd">

<InternalRouting>
<FromLab></FromLab>
<ToLab></ToLab>
</InternalRouting>
<AvailableLaboratories>
</AvailableLaboratories>
</TYPE3_GETLABS_RESPONSE>
=== End of Type3 Template =====

=== Lab Details Template ====
<LaboratoryDetails>
<Name/>
<LabCode/>
<Contact/>
<Telephone/>
<Address1/>
<Address2/>
<Postcode/>
</LaboratoryDetails>
=== End of Lab Details Template =====


--
Thanks,

Ewan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remove xmlns attribute from XML document (.net) fzhang@calamos.com XML 9 02-25-2012 04:41 AM
What does xmlns:xsi and xmlns:xsd attributes mean? afshar XML 3 05-19-2010 02:16 AM
Re: How to remove xmlns attribute from XML document (.net) Greg Collins [Microsoft MVP] XML 0 10-25-2006 04:31 PM
[RESEND] Need to remove blank XMLNS attribute from xmldocument =?Utf-8?B?RXdhbiBGYWlyd2VhdGhlcg==?= ASP .Net 1 04-18-2006 01:39 PM
xmlns:SOAP-ENC, xmlns:xsd required? chris.stromberger@gmail.com XML 0 10-26-2005 02:48 PM



Advertisments