System.Xml.XmlTextWriter.LookupPrefix C# (CSharp) Method

LookupPrefix() public method

public LookupPrefix ( string ns ) : string
ns string
return string
        public override string LookupPrefix(string ns) {
            if (ns == null || ns.Length == 0) {
                throw new ArgumentException(Res.GetString(Res.Xml_EmptyName));
            }
            string s =  FindPrefix(ns);
            if (s == null && ns == stack[top].defaultNs) {
                s = string.Empty;
            }
            return s;
        }

Usage Example

Example #1
0
        void WriteComplexTypeSample(XmlTextWriter xtw, XmlSchemaComplexType stype, XmlQualifiedName rootName, int id)
        {
            string ns = rootName.Namespace;

            if (rootName.Name.IndexOf("[]") != -1) rootName = arrayType;

            if (currentUse == SoapBindingUse.Encoded) {
                string pref = xtw.LookupPrefix(rootName.Namespace);
                if (pref == null) pref = "q1";
                xtw.WriteStartElement(pref, rootName.Name, rootName.Namespace);
                ns = "";
            }
            else
                xtw.WriteStartElement(rootName.Name, rootName.Namespace);

            if (id != -1) {
                xtw.WriteAttributeString("id", "id" + id);
                if (rootName != arrayType)
                    xtw.WriteAttributeString("type", XmlSchema.InstanceNamespace, GetQualifiedNameString(xtw, rootName));
            }

            WriteComplexTypeAttributes(xtw, stype);
            WriteComplexTypeElements(xtw, ns, stype);

            xtw.WriteEndElement();
        }
All Usage Examples Of System.Xml.XmlTextWriter::LookupPrefix