Hi Deken,
For information if your attribute is a non-string type you need to enter
value in this field for that Infopath accept to validate it.
For add an attribute with C# you can do the following:
//Select the element where you want to insert your attribut
IXMLDOMElement oElement =
(IXMLDOMElement)thisXDocument.DOM.selectSingleNode("/Root/yourElement");
IXMLDOMAttribute NewAttribute =
(IXMLDOMAttribute)loesch.ownerDocument.createNode((int)DOMNodeType.NODE_ATTRIBUTE, "AttributeName", "");
NewAttribute.text = "AtrributeValue";
oElement.setAttributeNode(NewAttribute);
Hope this Help
Thierry Coita
> In Infopath 2003, is it possible to add a missing optional attribute to an
> element?
[quoted text clipped - 12 lines]
>
> Deken
Thierry Coita - 02 Apr 2007 10:36 GMT
In my original example loesch is a IXMLDOMNode so please replace it by:
thisXDocument.DOM.selectSingleNode("/Root/yourElement")
for that my example work.
Deken - 02 Apr 2007 19:26 GMT
Thank you, Thierry. Unfortunately, this doesn't help. First, for a variety
of reasons, we're unable to use managed code, so C# is not available. I
could probably translate into JScript but don't see the point: When the
dropdown list is changed no event appears to fire before the node is reported
to be read-only and the action fails. Not even "OnBeforeChange" works - a
breakpoint set in that event handler (using the "debugger;" statement) is
never reached. OnLoad for the document might work, and I could add the
attribute for each location where it's allowed but that effectively makes the
attribute required, which is not what we want.
I suspect that there's something I'm missing but I am missing it.
I do appreciate your assistance, though!
Deken
> Hi Deken,
>
[quoted text clipped - 31 lines]
> >
> > Deken