Add an attribute - InfoPath Dev
in

InfoPath Dev

Add an attribute

Last post 09-07-2005 11:41 PM by Coita Thierry. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 09-05-2005 07:40 AM

    Add an attribute

    Hi,

    I have read this topic:

    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=313

    I want to add a attribute optionnal but define by my custom schema!

    My Code:
    IXMLDOMElement oElement = (IXMLDOMElement)NewMut;	
    IXMLDOMAttribute Aenderung = (IXMLDOMAttribute)NewMut.ownerDocument.createNode((int)DOMNodeType.NODE_ATTRIBUTE, "Aenderung", "http://zefix.powernet.ch/Schema/HRG.xsd");
    Aenderung.text = "1";
    oElement.setAttributeNode(Aenderung);

    But he say that is not declared to in the namespace:
    quote:
    System.Runtime.InteropServices.COMException
    The attribute 'http://zefix.powernet.ch/Schema/HRG.xsd}Aenderung' on the element 'Person' is not defined in the DTD/Schema.
    at Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMElement.setAttributeNode(IXMLDOMAttribute DOMAttribute)
    at Microsoft.Office.Interop.InfoPath.SemiTrust.DOMNodeWrapper.setAttributeNode(IXMLDOMAttribute attribute)
    at Microsoft.Office.Interop.InfoPath.SemiTrust.DOMNodeWrapper.setAttributeNode(IXMLDOMAttribute attribute)
    at Req2.Req2.MutPers_OnClick(DocActionEvent e) in c:\documents and settings\tc\bureau\st gallen\visual studio projects\req2\formcode.cs:line 144
    at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)


    In my schema there are an Aenderung attribute optionnal :

    http://zefix.powernet.ch/infopath/schema.jpg

    So What is the namespace that I need to declare? For that work

    Thanks for your help!

    ++

    Thierry



    Every moment hesitated is a moment gone for life!!! Think about it
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 09-06-2005 05:53 AM In reply to

    I have found! It's easy no namespace no declaration:

    IXMLDOMElement oElement = (IXMLDOMElement)NewMut;
    IXMLDOMAttribute Aenderung = (IXMLDOMAttribute)NewMut.
    ownerDocument.createNode((int)DOMNodeType.NODE_ATTRIBUTE, "Aenderung", "");
    Aenderung.text = "1";
    oElement.setAttributeNode(Aenderung);

    ++

    Thierry

    Every moment hesitated is a moment gone for life!!! Think about it
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 09-07-2005 01:12 AM In reply to

    Sorry Thierry for not responding sooner, but looks like you found and fixed your problem. The namespace issue is something that everyone hits at least once!

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 09-07-2005 11:41 PM In reply to

    The namespaces are greats in xml he gives a lot of advantage and the flexibility! But It's very hard to manage it without making some errors...

    Every moment hesitated is a moment gone for life!!! Think about it
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.