XML skeleton in the cupboard

  • Thread starter Thread starter gentlerobbin
  • Start date Start date
G

gentlerobbin

I 'd like to write element contents into nodes of an XML

Example,

<application>
<windows>
<Version>
I want to write something here
<Version>
</windows>
<Linux>
<KDE>
<Game>I want to write something here</Game>
</KDE>
<Fedora>
I want to write something here
</Fedora>
</Linux>
<Mac "I want to write something here" />
</application>

How can I fill the XML with anything in places of "I want to write
something here" ??

Thanks
 
I 'd like to write element contents into nodes of an XML

Example,

<application>
<windows>
<Version>
I want to write something here
<Version>
</windows>
<Linux>
<KDE>
<Game>I want to write something here</Game>
</KDE>
<Fedora>
I want to write something here
</Fedora>
</Linux>
<Mac "I want to write something here" />
</application>

How can I fill the XML with anything in places of "I want to write
something here" ??

Thanks
Plenty of ways. One is to open the XML in an System.Xml.XmlDocument and
retrieve the target elements using XPath. Then use the InnerText property:
XmlDocument doc = new XmlDocument();
XmlElement version = doc.SelectSingleNode("/*/Windows/Version") as
XmlElement;
version.InnerText = "new text here";
MessageBox.Show(doc.DocumentElement.OuterXml);


Use the Save method to commit changes.
 
I have no idea what you are actually asking but this is my best guess.

<Game>I want to write something here</Game>
<Mac someAttributeName="I want to write something here" />
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top