Jak umieścić atrybuty przez XElement
Mam ten kod:
XElement EcnAdminConf = new XElement("Type",
new XElement("Connections",
new XElement("Conn"),
// Conn.SetAttributeValue("Server", comboBox1.Text);
//Conn.SetAttributeValue("DataBase", comboBox2.Text))),
new XElement("UDLFiles")));
//Conn.
Jak umieścić atrybuty na Conn? Chcę umieścić te atrybuty, które oznaczyłem jako komentarze, ale jeśli spróbuję ustawić atrybuty na Conn po zdefiniowaniu EcnAdminConf
, nie są one widoczne... Więc chcę je jakoś ustawić, aby XML zaczął wyglądać tak:
<Type>
<Connections>
<Conn ServerName="FAXSERVER\SQLEXPRESS" DataBase="SPM_483000" />
<Conn ServerName="FAXSERVER\SQLEXPRESS" DataBase="SPM_483000" />
</Connections>
<UDLFiles />
</Type>
109
1 answers
Dodaj XAttribute
w konstruktorze XElement
, Jak
new XElement("Conn", new XAttribute("Server", comboBox1.Text));
Możesz również dodać wiele atrybutów lub elementów za pomocą konstruktora
new XElement("Conn", new XAttribute("Server", comboBox1.Text), new XAttribute("Database", combobox2.Text));
Lub możesz użyć metody Add XElement
, Aby dodać atrybuty
XElement element = new XElement("Conn");
XAttribute attribute = new XAttribute("Server", comboBox1.Text);
element.Add(attribute);
223
Author: Jehof,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-08-23 12:13:55
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-08-23 12:13:55