473,666 Members | 2,157 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Attribu tes.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 19025
Nabeel Moeen wrote:
I want to add the xsi:nil="true' attribute to an element in XML. I am using
XmlNode.Attribu tes.Append() but the generated output results in the attribute
[nil="true"] ignoring the "xsi:" prefix.
It works like this, using CreateAttribute and SetAttributeNod e:

XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Loa dXml(@"<foo><ba r/></foo>");
XmlElement bar = xmlDocument.Doc umentElement["bar"];
XmlAttribute xsinil = xmlDocument.Cre ateAttribute("x si", "nil",
"http://www.w3.org/2001/XMLSchema-instance");
xsinil.Value = "true";
bar.SetAttribut eNode(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
1904
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 element which reads: <xsd:element name="DoubleValue" type="xsd:double" nillable="true"/> In my instance document I have the following element:
0
4080
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 using complex type structures declared in the WSDL file.
0
3515
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 IsNullable=true attribute <xs:element name="SSN" type="xs:string" minOccurs="0" nillable="true"/> /// <remarks/>
0
1231
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, it inserts 'xsi:nil="true"' for each of those elements, which is a violation of my schema (and logic). (The code below is for cataloging laboratory instruments. The element "calibrationtuid" is a globally unique identification string which...
3
2622
by: KillerJ | last post by:
I found a post about this exact issue: http://groups.google.com/group/microsoft.public.dotnet.xml/browse_thread/thread/1dfeb38170cb0b1/ea073666a4035bd5?lnk=st&q=decimal+parse+error+loading+dataset&rnum=6&hl=en#ea073666a4035bd5 but it only shows how to correct the issue manually, not whether it is a known bug. My situation is slightly different only in that the xml data and schema I have are coming directly from the DataSet using:...
13
1755
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
1152
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 these objects, they are not set to null, but int=0, bool=false etc. My client expects null ints to be Int32.MinValue, for example. SO, what I have done is write a filter for the client, which transforms the incoming SOAP packets with XSL.
0
1599
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 this example a string) in my schema. 2. When I convert this to a class (using xsd.exe) all is well. There is nothing in the code that is created to suggest that the field create is mandatory or otherwise. 3. When I render run the project and...
0
1815
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 Xml.XmlTextWriter, creating each element node since the agency I'm sending the file to is very specific about the format. How do I specify an element/node/attribute (whatever) to output xsi:nil="true"? Desired Output: <D02 xsi:nil="true" /> ...
0
8454
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8362
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8785
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8644
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7389
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6200
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5671
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.