Xmldeclaration. standalone attributes

Source: Internet
Author: User

Standalone attribute found in sharpdevelop, which is explained on msdn

Obtains or sets the value of an independent attribute.

If all object declarations required by the XML document are included in the document, the valid value is yes, or if the external document type definition (DTD) is required, no.
If the XML declaration does not contain an independent attribute, the property will return string. Empty.

The following example creates an xmldeclaration node and adds it to the XML document.

Using system;
Using system. IO;
Using system. xml;

Public class sample
...{

Public static void main ()
...{

// Create and load the XML document.
Xmldocument Doc = new xmldocument ();
String xmlstring = "<book> <title> Oberon's legacy </title> </book> ";
Doc. Load (New stringreader (xmlstring ));

// Create an XML declaration.
Xmldeclaration xmldecl;
Xmldecl = Doc. createxmldeclaration ("1.0", null, null );
Xmldecl. Encoding = "UTF-8 ";
Xmldecl. standalone = "yes ";

// Add the new node to the document.
Xmlelement root = Doc. documentelement;
Doc. insertbefore (xmldecl, root );

// Display the modified XML document
Console. writeline (Doc. outerxml );

System. Console. Read ();

}
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.