473,396 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

programatically adding attribute xsi:nil=true to XML element

Hi,
I want to add the xsi:nil="true' attribute to an element in XML. I am using
XmlNode.Attributes.Append() but the generated output results in the attribute
[nil="true"] ignoring the "xsi:" prefix.

How do I work around this problem?.

May 15 '07 #1
1 18934
Nabeel Moeen wrote:
I want to add the xsi:nil="true' attribute to an element in XML. I am using
XmlNode.Attributes.Append() but the generated output results in the attribute
[nil="true"] ignoring the "xsi:" prefix.
It works like this, using CreateAttribute and SetAttributeNode:

XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(@"<foo><bar/></foo>");
XmlElement bar = xmlDocument.DocumentElement["bar"];
XmlAttribute xsinil = xmlDocument.CreateAttribute("xsi", "nil",
"http://www.w3.org/2001/XMLSchema-instance");
xsinil.Value = "true";
bar.SetAttributeNode(xsinil);

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 15 '07 #2

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

Similar topics

0
by: Stefan Prange | last post by:
Hi everyone, I have a little problem here and wasn't able to find a proper solution by searching the web. So this newsgroups is my last resort ;-) I have an xml-schema definition of an...
0
by: Matt S | last post by:
Hello, I'm trying to build a C# client to consume an AXIS Web Service (running SOAP over HTTP). The Web Service encodes full server-side exception traces in the Soap Fault > Detail element...
0
by: John Jenkins | last post by:
Hi, can someone tell me why the following scneario occurs. With the nillable attribute set to true on an element that has min occurs set to zero, I generate a class. As expected this adds the...
0
by: Greg | last post by:
I'm writing a program which uses the ImportNode function of an XMLDataDocument. This works fine for elements which may appear once at most; however, for elements which may appear multiple times,...
3
by: KillerJ | last post by:
I found a post about this exact issue: ...
13
by: Jiho Han | last post by:
Here's the issue. You have a class, Class Person { public int id; public string firstname; public string lastname; }
0
by: Adam | last post by:
I am attempting to get a .net 1.1 client to interoperate with a .net 2.0 web service. The web service returns objects that contains fields of nullable types. Obviously when the 1.1 client receives...
0
by: Bakunin | last post by:
Hi, I have a brief question regarding the .net framework renders class definitions of schemas to wsdl descritions. I have observed the following: 1. I have a schema with a mandatory field (in...
0
by: jazzygirl | last post by:
I'm fairly new to vb.net (self-taught and realizing how much I DON'T know). I need to create an XML output file (I'm quite ignorant in this area as well!). I used an XMLDataDocument and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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
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
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...

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.