Ensure XML Namespace Defined - CSharp System.Xml

CSharp examples for System.Xml:XML Namespace

Description

Ensure XML Namespace Defined

Demo Code

// The .NET Foundation licenses this file to you under the MIT license.
using System.Xml;
using System.Text;

public class Main{
        internal static string EnsureNamespaceDefined(XmlDictionaryWriter writer, XmlDictionaryString ns, string defaultPrefix)
        {//from   w  w w  .  ja  va 2s  .  c  o m
            string p = writer.LookupPrefix(ns.Value);
            if (p == null)
            {
                writer.WriteXmlnsAttribute(defaultPrefix, ns);
                p = defaultPrefix;
            }

            return p;
        }
}

Related Tutorials