add nillable element to IXMLDOMDocument

D

DolceVita

Hi,

I code in C#

What I try to do is load a xml in string in a IXMLDOMDocument and that
make a validation error:

the attribute xsi:nil on "Date" element is not valid!

What I try to insert is a nillable element my schema in infopath accept
this no problem but if I try to load that in my IXMLDOMDocument I have
an error!

My code:

IXMLDOMDocument AVxml = (IXMLDOMDocument)thisXDocument.CreateDOM();
AVxml.loadXML("<AV xmlns=''
xmlns:tsd='http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition'

xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<AVel >
<Title>Statutendatum</Title>
<Date xsi:nil='true'/>
</AVel>
</AV>");


What I need to make for that don't make me this error of parsing?

Thanks a lot
 
S

S.Y.M. Wong-A-Ton

Not sure why it isn't working, but I suspect that it's a namespace issue. You
could try loading the XML without the attribute, and then afterwards use
"setAttribute" to set the attribute and its value. Do something like the
following after the loadXML:

((IXMLDOMElement)AVxml.selectSingleNode("//Date")).setAttribute("xsi:nil",
"true");
 
D

DolceVita

Hi,

Your idea is good but that don't satisfy me for a lot of reason!

I don't want to change my xml 20 times before and after the load in the
IXMLDOMDocument. It's not really good for the performance of my form.

I Have seen in debug mode (Visual studio 2005) when I try to load this
XMLDocument in my IXMLDOMDocument:

- parseError =
{Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMParseErrorWrapper}
errorCode = -1072897995
reason = "the xsi:nil attribut on the « Date » element isn't
valid.\r\n"

So how I can correct this? I need to declare a namespace in my
IXMLDOMDocument before load the other XML ?

Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top