Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Encounter error in XML

Encounter error in XML

Scheduled Pinned Locked Moved XML / XSL
helpxmlquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gregg Holter
    wrote on last edited by
    #1

    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...

    D 1 Reply Last reply
    0
    • G Gregg Holter

      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...

      D Offline
      D Offline
      DavidNohejl
      wrote on last edited by
      #2

      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.)

      G 1 Reply Last reply
      0
      • D DavidNohejl

        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.)

        G Offline
        G Offline
        Gregg Holter
        wrote on last edited by
        #3

        Hi David!I was able to fix it. I simply forget to close the node:) Thanks for the help. ---------------------- Seeing the infinite...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups