Home > front end >  C # the DataTable to turn XML no root node
C # the DataTable to turn XML no root node

Time:09-19

Private string ConvertDataTableToXML (DataTable xmlDS)
{
MemoryStream stream=null;
XmlTextWriter writer=null;
Try
{
The stream=new MemoryStream ();
Writer=new XmlTextWriter (stream, Encoding UTF8);
XmlDS. WriteXml (writer);
Int count=(int) stream. Length;
Byte [] arr=new byte (count);
Stream. Seek (0, SeekOrigin. Begin);
Stream. Read (arr. Zero, count);
UTF8Encoding utf=new and UTF8Encoding (); and
Return utf. Get string (arr). The Trim ();
}
Catch
{
Return a String. The Empty;
}
The finally
{
If (a writer!=null) writer. The Close ();
}
}
Method USES the generated XML for use after

? - 10 & lt;/QUANTITY>
- 600 & lt;/QUANTITY>
- 2 & lt;/QUANTITY>

Why there is no
<? The XML version="1.0" encoding="utf-8" standalone="yes"?>

CodePudding user response:

I think the format is & lt; ? The XML version="1.0" encoding="utf-8" standalone="yes"?>

And I transformed into & lt; NewDataSet>
  • Related