XmlDocument doc = new XmlDocument(); // Creating an xml document
XmlElement root =doc.CreateElement("rootelement"); doc.AppendChild(root); // Creating and appending the root element
XmlElement annotation = doc.CreateElement("Name");
XmlElement value = doc.CreateElement("Value");
annotation.InnerText = "Annotation Name Here";
value.InnerText = "Value Here";
doc.AppendChild(annotation);
doc.AppendChild(value);
var x = new MyStuff {
Name = "Stuff",
Annotations = new [] {
new Annotation { Name = "Note1", Value = "blah" },
new Annotation { Name = "Note2", Value = "blahblah" }
}.ToList()
};
// turns into something like:
<MyStuff Name="Stuff" ann:Note1="blah" ann:Note2="blahblah" />
당신은 모든 목록을 좁히고 루프에서 같은 일을 할 수 있습니다.
출처
2014-04-09 16:47:20
HMB
xml이 직렬화 후 어떻게 보일지에 대한 정보를 제공해주십시오. – MUG4N
내 마지막 질문에 대한 마지막 줄. –