Encounter error in XML
-
Here's my code: try { _strContent = "Ethan" _xmlDoc.Load(".\\EMP.xml"); _docFrag = _xmlDoc.CreateDocumentFragment(); _docFrag.InnerXml = _strContent; _xmlDoc.DocumentElement.AppendChild(_docFrag); _xmlDoc.Save(".\\EMP.xml"); } catch(Exception exc) { MessageBox.Show(exc.ToString()); } The EMP.xml is already existing. I just used the above block of code to add new nodes into an existing EMP.xml file. But, I received this exception: This is an unexpected token. The expected token is 'EndElement' Unlikely though, the code performs its function. When I check the file, I saw that the node I am trying to add was there, its just that the error keeps on prompting. Will anyone help me? Thanks in advance! ---------------------- Seeing the infinite...
-
Here's my code: try { _strContent = "Ethan" _xmlDoc.Load(".\\EMP.xml"); _docFrag = _xmlDoc.CreateDocumentFragment(); _docFrag.InnerXml = _strContent; _xmlDoc.DocumentElement.AppendChild(_docFrag); _xmlDoc.Save(".\\EMP.xml"); } catch(Exception exc) { MessageBox.Show(exc.ToString()); } The EMP.xml is already existing. I just used the above block of code to add new nodes into an existing EMP.xml file. But, I received this exception: This is an unexpected token. The expected token is 'EndElement' Unlikely though, the code performs its function. When I check the file, I saw that the node I am trying to add was there, its just that the error keeps on prompting. Will anyone help me? Thanks in advance! ---------------------- Seeing the infinite...
well I don't know what exactly is problem there, maybe you already solved it (?). Ethan Marixxe Drater wrote: This is an unexpected token. The expected token is 'EndEleme That means syntax error in your XML. Surprisingly. :) Ethan Marixxe Drater wrote: Unlikely though, the code performs its function. When I check the file, I saw that the node I am trying to add was there, its just that the error keeps on prompting. Strange. Could you post small examples of input/output? Or at least where exactly exception raises? I mean what statement? _xmlDoc.Load(), _xmlDoc.Save(), AppendChild? Funny how can be debugging something about 10 lines difficult. I just failed test cuz of the same :(( David Never forget: "Stay kul and happy" (I.A.)
-
well I don't know what exactly is problem there, maybe you already solved it (?). Ethan Marixxe Drater wrote: This is an unexpected token. The expected token is 'EndEleme That means syntax error in your XML. Surprisingly. :) Ethan Marixxe Drater wrote: Unlikely though, the code performs its function. When I check the file, I saw that the node I am trying to add was there, its just that the error keeps on prompting. Strange. Could you post small examples of input/output? Or at least where exactly exception raises? I mean what statement? _xmlDoc.Load(), _xmlDoc.Save(), AppendChild? Funny how can be debugging something about 10 lines difficult. I just failed test cuz of the same :(( David Never forget: "Stay kul and happy" (I.A.)
Hi David!I was able to fix it. I simply forget to close the node:) Thanks for the help. ---------------------- Seeing the infinite...