का उपयोग कर एक्सएमएल फ़ाइल संलग्न करें "एक्सएमएलवाइटर" का उपयोग करने के पहले सुझाव के लिए धन्यवाद, हर बार जब यह नई एक्सएमएल फाइल बनाता है तो मैंने xml फ़ाइल को लोड करने के लिए xmldoc का उपयोग किया था, फिर उस फ़ाइल में संलग्न करें, यह मेरा कोड है लेकिन यह अपवाद फेंकता है " इस दस्तावेज़ में पहले से ही 'DocumentElement' नोड है। "xmlwriter
//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>
Am अग्रिम
में तरह<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>
नीचे धन्यवाद एक्सएमएल में संलग्न करने के लिए
यह उपयोगी है इस
आप इस
की तरह कुछ result'll कि तरह करने की जरूरत है की तरह uemnt? ................. –
बिल्कुल, उदाहरण के लिए बहुत बहुत धन्यवाद, मैंने अभी तक संशोधित नहीं किया है, मैं स्टार बनूंगा अब एक लिखना नहीं है। मैं कोड वापस यहां पोस्ट करूंगा। एक बार फिर धन्यवाद – Usher