7
"XMLWriter"를 사용할 때마다 새로운 XML 파일을 생성 할 때마다 xmldoc을 사용하여 XML 파일을로드 한 다음 여기에 코드를 추가하는 것이 좋습니다. 그러나 " 이 문서에는 이미 'DocumentElement'노드가 있습니다. " 여기 xmlwriter를 사용하여 xml 파일을 추가합니다.
//Append to xml file
XmlDocument doc = new XmlDocument();
doc.Load(@"c:\\test.xml");
using (XmlWriter xmlWrite = doc.CreateNavigator().AppendChild())
{
xmlWrite.WriteStartElement("image name=",Name);
xmlWrite.WriteElementString("width", widthValue[1]);
xmlWrite.WriteElementString("Height", heightValue[1]);
xmlWrite.WriteElementString("file-size", FileSizeValue[1]);
xmlWrite.WriteElementString("file-format", FileFormatValue[1]);
xmlWrite.WriteElementString("resolution", ResolutionValue[1]);
xmlWrite.Close();
}
내 샘플 test.xml의입니다
<job-metadata>
<slug>730s_Sales/CupWinner_0111</slug>
<locations>Africa</locations>
<primary-location>Africa</primary-location>
<reporter>Leigh Sales</reporter>
<genre>Current</genre>
<copyright>CBS</copyright>
<autopublish>true</autopublish>
</job-metadata>
하고있는 XML 데이터를 재생하려면 사전
에<job-metadata>
<slug>730s_Sales/CupWinner_0111</slug>
<locations>Africa</locations>
<primary-location>Africa</primary-location>
<reporter>Leigh Sales</reporter>
<genre>Current</genre>
<copyright>CBS</copyright>
<autopublish>true</autopublish>
- <image name="557684_20111101-730s_SalesCupWinner_0111_80x60.jpg">
<width>80</width>
<height>60</height>
<file-size>7045</file-size>
<file-format>JPEG Baseline</file-format>
<resolution>72</resolution>
<custom-name>newsthumbnail</custom-name>
</image>
</job-metadata>
아래 덕분에 같은 XML에
이 도움이됩니다 당신은 result'll 그런 일이
같은 것을 할 필요가이
같은 uemnt? ................. –
절대적으로 고마워요. 예를 들어, 아직 수정하지 않았습니다. 별표를 표시합니다. 지금 글 쓰는 중. 여기에 코드를 다시 게시합니다. 다시 한 번 감사드립니다. – Usher