سلام بر تمامی برنامه نویسان سی شارپ 😉 در این مطلب کد ساخت یک XML document با تعیین کردن عناصر در سی شارپ را آماده کردم. انشاالله که این کد براتون مفید باشه.
خروجی این کد به این صورت است:
myAuthor10.0
کد ساخت یک XML document با تعیین کردن عناصر در سی شارپ :
using System;
using System.Collections;
using System.Data;
using System.Xml;
public class MainClass {
public static void Main() {
XmlDocument doc = new XmlDocument();
XmlElement root = doc.CreateElement( "books" );
doc.AppendChild( root );
XmlElement eltBook = doc.CreateElement( "book" );
root.AppendChild( eltBook );
XmlElement eltTitle = doc.CreateElement( "title" );
eltTitle.AppendChild( doc.CreateTextNode( "myTitle" ) );
using System.Collections;
using System.Data;
using System.Xml;
public class MainClass {
public static void Main() {
XmlDocument doc = new XmlDocument();
XmlElement root = doc.CreateElement( "books" );
doc.AppendChild( root );
XmlElement eltBook = doc.CreateElement( "book" );
root.AppendChild( eltBook );
XmlElement eltTitle = doc.CreateElement( "title" );
eltTitle.AppendChild( doc.CreateTextNode( "myTitle" ) );