473,396 Members | 1,671 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 18932
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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,...

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.