반응형
XElement를 통해 속성을 넣는 방법
이 코드가 있습니다.
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.
Conn에 속성을 넣는 방법? 주석으로 표시 한이 속성을 그래서 싶지만 정의 후 속성을 Conn으로 설정 하려고 하면 속성 EcnAdminConf
을 ... XML 다음과 같이 보이게하기 위해 어떻게 든 설정하고 싶습니다.
<Type>
<Connections>
<Conn ServerName="FAXSERVER\SQLEXPRESS" DataBase="SPM_483000" />
<Conn ServerName="FAXSERVER\SQLEXPRESS" DataBase="SPM_483000" />
</Connections>
<UDLFiles />
</Type>
XAttribute
의 생성자에 다음 XElement
과 같이 추가하십시오 .
new XElement("Conn", new XAttribute("Server", comboBox1.Text));
생성을 통해 여러 속성 또는 요소를 추가 할 수도 있습니다.
new XElement("Conn", new XAttribute("Server", comboBox1.Text), new XAttribute("Database", combobox2.Text));
또는 추가 방법을 사용하여 XElement
속성을 추가 할 수 있습니다.
XElement element = new XElement("Conn");
XAttribute attribute = new XAttribute("Server", comboBox1.Text);
element.Add(attribute);
참고 URL : https://stackoverflow.com/questions/5063936/how-to-put-attributes-via-xelement
반응형
'IT' 카테고리의 다른 글
ssrs 보고서에서 날짜 및 시간을 어떻게 형식화합니까? (0) | 2020.07.13 |
---|---|
여러 HTML 페이지에 포함 할 머리글 및 바닥 글 파일 만들기 (0) | 2020.07.13 |
Mac에서 여러 MonoDevelop 인스턴스를 시작해야합니까? (0) | 2020.07.13 |
Clojure Core 또는 Contrib에 Zip 기능과 동등한 기능이 있습니까? (0) | 2020.07.13 |
CSS 콘텐츠 태그에서 nbsp가 작동하지 않음 (0) | 2020.07.13 |