System.Xml.XmlDocument.CreateAttribute C# (CSharp) Method

CreateAttribute() public method

public CreateAttribute ( string prefix, string localName, string namespaceURI ) : XmlAttribute
prefix string
localName string
namespaceURI string
return XmlAttribute
        public virtual XmlAttribute CreateAttribute(string prefix, string localName, string namespaceURI)
        {
            return new XmlAttribute(AddAttrXmlName(prefix, localName, namespaceURI, null), this);
        }

Same methods

XmlDocument::CreateAttribute ( String name ) : XmlAttribute
XmlDocument::CreateAttribute ( String qualifiedName, String namespaceURI ) : XmlAttribute

Usage Example

    //
    //  METHOD      : BuildDetail
    //  DESCRIPTION : Create bulk of error log, parameters fill in the specific details like error type, variable name, and explanation
    //  PARAMETERS  : string name                 - Variable name
    //                string type                 - Error type
    //                string explanation          - Explanation of error
    //  RETURNS     : XmlNode node                - XML containing constructed log.
    //
    public XmlNode BuildDetail(string name, string type, string explanation)
    {
        XmlDocument  doc  = new System.Xml.XmlDocument();
        XmlNode      node = doc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);
        XmlNode      details;
        XmlAttribute nameAttr;
        XmlAttribute errorTypeAttr;
        XmlAttribute explanationAttr;

        details               = doc.CreateNode(XmlNodeType.Element, "ParameterError", "http://localhost/LoanService");
        nameAttr              = doc.CreateAttribute("s", "name", "http://localhost/LoanService");
        nameAttr.Value        = name;
        errorTypeAttr         = doc.CreateAttribute("s", "errorType", "http://localhost/LoanService");
        errorTypeAttr.Value   = type;
        explanationAttr       = doc.CreateAttribute("s", "explanation", "http://localhost/LoanService");
        explanationAttr.Value = explanation;

        details.Attributes.Append(nameAttr);
        details.Attributes.Append(errorTypeAttr);
        details.Attributes.Append(explanationAttr);

        node.AppendChild(details);

        return(node);
    }
All Usage Examples Of System.Xml.XmlDocument::CreateAttribute