5

I have an xml document that looks like this

<?xml version="1.0"?>
<XML>
    <VIDEO>
        <WIDTH>800</WIDTH>
        <HEIGHT>600</HEIGHT>
        <COLORBITS>32</COLORBITS>
        <GAMMA>255</GAMMA>
        <FULLSCREEN>TRUE</FULLSCREEN>
        <REFLECTION>true</REFLECTION>
        <LIGHTMAP>true</LIGHTMAP>
        <DYNAMICLIGHT>true</DYNAMICLIGHT>
        <SHADER>true</SHADER>
        <CHARACTORTEXTURELEVEL>0</CHARACTORTEXTURELEVEL>
        <MAPTEXTURELEVEL>0</MAPTEXTURELEVEL>
        <EFFECTLEVEL>0</EFFECTLEVEL>
        <TEXTUREFORMAT>1</TEXTUREFORMAT>
        <NHARDWARETNL>false</NHARDWARETNL>
    </VIDEO>    
</XML>

I want to change the value of the "MAPTEXTURELEVEL" node from 0 to 6 using the checked statement of a checkbox in a C# application, but I really have no idea of how I can do it.

1
  • Please don't prefix your titles with "C#" and such. That's what the tags are for. Commented Dec 29, 2011 at 0:11

1 Answer 1

5

I don't have VS to test it, but it should be something like this using LINQ to XML:

var doc = XDocument.Load("video.xml");
doc
    .Element("XML")
    .Element("VIDEO")
    .SetElementValue("MAPTEXTURELEVEL", 6);
doc.Save("video_modified.xml");

Hope it helps!

Sign up to request clarification or add additional context in comments.

1 Comment

I have updated your code snipped to make it compile. It is indeed right answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.