element not appeneding


Answer this question

element not appeneding

  • AndyW027

    XmlNode root = mainDoc.DocumentElement;
    FileStream fs = new FileStream(pathToXML, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
    mainDoc.Load(fs);

    You first took pointer to your DocumentElement and then reload the document.

    After this node you hold in the "root" variable doesn't belong the "mainDoc" any more.

    To conform that this is the problem you can add:

    Debug.Assert(root == mainDoc.DocumentElement);

    It should fail.



  • B M E

    Thanks a lot, fixed now.

    I removed the passing of the xmldocument to the constructor, just passed the path to it and loaded the doc from within the class. Changed the findthis value a bit and now robert's your mother's brother.

    Ta.


  • element not appeneding