End Google Ads 201810 - BS.net 01 -->
Hi (im German so please forgive my bad english),
I wrote a c# .net 4.0 Program that gives me results from different calculations into different variables with different datatypes (myInt, myDouble, myString, myBool, myWhatevr)
Now i wanted to give al this results to my xml file that is used as a logfile.
This is my xml code:
using System;
using System.Xml;
namespace xml_exporter
{
public class xml_tool
{
public static void tel_toXML()
{
string dateTime = DateTime.Now.ToString("yyyyMMddhhmmss");
XmlTextWriter myXmlTextWriter = new XmlTextWriter("C:\\XML-Log_" + dateTime + ".xml", System.Text.Encoding.UTF8);
myXmlTextWriter.Formatting = Formatting.Indented;
myXmlTextWriter.WriteStartDocument(true);
myXmlTextWriter.WriteStartElement("Data");
myXmlTextWriter.WriteComment("Start");
myXmlTextWriter.WriteElementString("Farbe", "Blau"); //non variable value "blau"
myXmlTextWriter.WriteElementString("Struktur:", "Rau");
myXmlTextWriter.WriteComment("Farbnummer" ""); //now variable value's => ("Colornumber" "myint");
myXmlTextWriter.WriteElementString("Dichte", ""); //myDouble
myXmlTextWriter.WriteElementString("Name", ""); //myString
myXmlTextWriter.WriteElementString("Aktiv", ""); //myBool
myXmlTextWriter.WriteComment("End");
myXmlTextWriter.WriteEndElement();
myXmlTextWriter.Flush();
myXmlTextWriter.Close();
}
}
}
Now i want to know how to give my variabel values to the xml construct!?
so that the xml-file should look "like" this:
Colornumber ValueOfmyInt variable Colornumber
..
Dichte 5.4 Dichte
etc.
However I searched in the c# openbook, msdn I didnt found the right answer to my problem. And there must be a Code or a Command to give the values of my variable to the XML thing.
I'm just always finding "how to read from xml" and stuff but thats not the same I think. Im still trying to build something up but its not working.
Ich flehe um Hilfe!
Does anyone have an idea how i can realise this ? Or a Link for exact this problem etc.? It would be a very big help for me.
greetz,
Sal
مواقع النشر (المفضلة)