Method ForceNSDecl
ForceNSDecl(String)
Force a Namespace to be declared on the root element.
By default, the XMLWriter will declare only the Namespaces needed for an element; as a result, a Namespace may be declared many places in a document if it is not used on the root element.
This method forces a Namespace to be declared on the root element even if it is not used there, and reduces the number of xmlns attributes in the document.
Declaration
public virtual void ForceNSDecl(string uri)
Parameters
Type | Name | Description |
---|---|---|
System.String | uri | The Namespace URI to declare. |
See Also
ForceNSDecl(String, String)
Force a Namespace declaration with a preferred prefix.
This is a convenience method that invokes SetPrefix(String, String) then ForceNSDecl(String).
Declaration
public virtual void ForceNSDecl(string uri, string prefix)
Parameters
Type | Name | Description |
---|---|---|
System.String | uri | The Namespace URI to declare on the root element. |
System.String | prefix | The preferred prefix for the Namespace, or "" for the default Namespace. |