Click here to Skip to main content
15,881,803 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to Improve Win From's Graphics !! Pin
LongRange.Shooter19-Apr-06 3:52
LongRange.Shooter19-Apr-06 3:52 
AnswerRe: How to Improve Win From's Graphics !! Pin
Robert Rohde19-Apr-06 4:48
Robert Rohde19-Apr-06 4:48 
Questiondataset problem Pin
Khepry19-Apr-06 3:17
Khepry19-Apr-06 3:17 
AnswerRe: dataset problem Pin
LongRange.Shooter19-Apr-06 3:30
LongRange.Shooter19-Apr-06 3:30 
Questionpopup menu Pin
vatzcar19-Apr-06 3:11
vatzcar19-Apr-06 3:11 
AnswerRe: popup menu Pin
LongRange.Shooter19-Apr-06 3:26
LongRange.Shooter19-Apr-06 3:26 
QuestionEditing an XML node in C# Pin
AnneThorne19-Apr-06 2:48
AnneThorne19-Apr-06 2:48 
AnswerRe: Editing an XML node in C# Pin
LongRange.Shooter19-Apr-06 3:19
LongRange.Shooter19-Apr-06 3:19 
The use of XmlTextReader and XmlTextWriter is more for loading and persisting the data. You would load the data into an XmlDocument and then modify it there. You should also be aware of the fact that your Xml is not well-formed. You cannot have value containing two instances of choicelist and choicevalue. You need to do something like
<ListValues>
    <Values>
        <choiceList />
        <choiceValue />
    </Values>
    <Values>
        <choiceList />
        <choiceValue />
    </Values>
</ListValues>


IMHO -- Navigating the DOM is a PITA. I prefer to avoid it whenever possible....especially if your application is creating/destroying xml objects quite alot. (You see the Xml engine in 2002, 2003 VS leaks memory)

A really simple approach ( I like KIS ) is to create an object that represents your data and use XmlSerializer to populate/persist the data. Then your access of the data is normal object technology and you are saved from actual node/child navigation. The sample below is only from shear memory (my VS machine is dead) so the exactness is not guarenteed.

C#
[Serializable()]
public class lable
{
    public string name{get; set;}
    public string type{get; set;}
    public Value value{get; set;}
}
[Serializable()]
public class ValueList:List<Values>
{
}
[Serializable()]
public class Values
{
    public string choiceList{ get; set; }
    public string choiceValue{ get; set; }
}

public class XmlAccessor
{
    public lable GetData(string path);
    {
        using (FileStream stream = new FileStream(path, FileMode.Open))
        {
            XmlSerializer ser = new XmlSerializer(typeof(lable));
            lable Lable = (lable)ser.Deserialize(stream);
        }
        return Lable;
    }
    public void PutData( string path, lable item )
    {
        using (FileStream stream = new FileStream(path, FileMode.Create))
        {
            XmlSerializer ser = new XmlSerializer(typeof(lable));
            ser.Serialize(stream, item);
        }
    }

My only recommendation....if possible I'd change the casing on the lables so that they are Pacal cased.
AnswerRe: Editing an XML node in C# Pin
conrado719-Apr-06 3:32
conrado719-Apr-06 3:32 
QuestionBluetooth in C# Pin
hschutte19-Apr-06 2:21
hschutte19-Apr-06 2:21 
AnswerRe: Bluetooth in C# Pin
LongRange.Shooter19-Apr-06 3:24
LongRange.Shooter19-Apr-06 3:24 
QuestionHTMLdocument and Webclient/Webbrowser Pin
ranzask19-Apr-06 2:12
ranzask19-Apr-06 2:12 
AnswerRe: HTMLdocument and Webclient/Webbrowser Pin
Ed.Poore19-Apr-06 9:19
Ed.Poore19-Apr-06 9:19 
AnswerRe: HTMLdocument and Webclient/Webbrowser Pin
Ravi Bhavnani19-Apr-06 9:26
professionalRavi Bhavnani19-Apr-06 9:26 
GeneralRe: HTMLdocument and Webclient/Webbrowser Pin
ranzask19-Apr-06 9:40
ranzask19-Apr-06 9:40 
GeneralRe: HTMLdocument and Webclient/Webbrowser Pin
Ravi Bhavnani19-Apr-06 9:47
professionalRavi Bhavnani19-Apr-06 9:47 
QuestionThreading program Pin
eric_tran19-Apr-06 1:52
eric_tran19-Apr-06 1:52 
AnswerRe: Threading program Pin
LongRange.Shooter19-Apr-06 5:26
LongRange.Shooter19-Apr-06 5:26 
GeneralRe: Threading program Pin
eric_tran19-Apr-06 5:48
eric_tran19-Apr-06 5:48 
QuestionUninstall link in deployment project Pin
Stefan Troschuetz19-Apr-06 1:41
Stefan Troschuetz19-Apr-06 1:41 
Questiondiscusiion forum Pin
prgramya19-Apr-06 1:41
prgramya19-Apr-06 1:41 
AnswerRe: discusiion forum Pin
J4amieC19-Apr-06 2:36
J4amieC19-Apr-06 2:36 
AnswerRe: discusiion forum Pin
LongRange.Shooter19-Apr-06 3:57
LongRange.Shooter19-Apr-06 3:57 
QuestionDetect when new application opened? Pin
Werner Vos19-Apr-06 1:32
Werner Vos19-Apr-06 1:32 
QuestionDirectoryNotFoundException when directory does exist Pin
sergestusxx19-Apr-06 1:19
sergestusxx19-Apr-06 1:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.