c# - How to set value of thr root element in XML file using LinQ? -
my xml file of form:
"<testfile fileext="c:\testfiles\testfile2.txt"> </testfile>"
here root element "testfile". task create new xml of form query using is:
xdocument doc = new xdocument( new xdeclaration("1.0", "utf-8", "yes"), new xcomment("this medtata file of file " + args[0]), new xelement("testfile",path));
but instead of
"<testfile fileext="c:\testfiles\testfile2.txt"> </testfile>"
, output
"<testfile>c:\testfiles\testfile2.txt</testfile>"
how can desired output?
try this
xdocument doc = new xdocument( new xdeclaration("1.0", "utf-8", "yes"), new xcomment("this medtata file of file " + args[0]), new xelement("testfile",new xattribute("filetext", path)));
if wanna add value inside add next argument in xelement
exmaple
xdocument doc = new xdocument( new xdeclaration("1.0", "utf-8", "yes"), new xcomment("this medtata file of file " + args[0]), new xelement("testfile",new xattribute("filetext", path), "something"));
Comments
Post a Comment