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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. XML / XSL
  4. root element is missing

root element is missing

Scheduled Pinned Locked Moved XML / XSL
xmlhelpquestionannouncement
5 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.
  • A Offline
    A Offline
    Ahmed Galal
    wrote on last edited by
    #1

    whats wrong in this xml:

    <?xml version='1.0' encoding='utf-8'?>
    <root xmlns=''>
    <data xmlns=''>
    <name>ahmed galal</name>
    <name>tamer galal</name>
    </data>
    </root>
    

    if nothin wrong then why everytime i try to use XmlDocument.Load() it throws an System.Xml.XmlException with message "Root element is missing" any help ?

    D 1 Reply Last reply
    0
    • A Ahmed Galal

      whats wrong in this xml:

      <?xml version='1.0' encoding='utf-8'?>
      <root xmlns=''>
      <data xmlns=''>
      <name>ahmed galal</name>
      <name>tamer galal</name>
      </data>
      </root>
      

      if nothin wrong then why everytime i try to use XmlDocument.Load() it throws an System.Xml.XmlException with message "Root element is missing" any help ?

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

      I have no idea. But from the top of my head, try remove empty namespaces. David

      A 1 Reply Last reply
      0
      • D DavidNohejl

        I have no idea. But from the top of my head, try remove empty namespaces. David

        A Offline
        A Offline
        Ahmed Galal
        wrote on last edited by
        #3

        thanx for ur reply, i think i found the clue, but its not about namespaces at the begin i was reading the xml data from a stream using XmlDocument.Load() and thats why i had the problem, but finally i tried to read the stream into a string then i use XmlDocument.LoadXml() instead and thats worked fine, but i still don't know why i can't read from the stream directly while XmlDocument.Load() function supports that. anyway thanx :)

        D 1 Reply Last reply
        0
        • A Ahmed Galal

          thanx for ur reply, i think i found the clue, but its not about namespaces at the begin i was reading the xml data from a stream using XmlDocument.Load() and thats why i had the problem, but finally i tried to read the stream into a string then i use XmlDocument.LoadXml() instead and thats worked fine, but i still don't know why i can't read from the stream directly while XmlDocument.Load() function supports that. anyway thanx :)

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

          hmm I don't know but it could be some encoding issue.. was that xml file really UTF-8 encoded? I mean, try to open it in notepad and re-save with UTF-8 encoding. (assuming you have notepad in WinXP or similar which allows that. VS can do it too IIRC) David

          A 1 Reply Last reply
          0
          • D DavidNohejl

            hmm I don't know but it could be some encoding issue.. was that xml file really UTF-8 encoded? I mean, try to open it in notepad and re-save with UTF-8 encoding. (assuming you have notepad in WinXP or similar which allows that. VS can do it too IIRC) David

            A Offline
            A Offline
            Ahmed Galal
            wrote on last edited by
            #5

            actually its not a xml file, its just generated xml send through XmlHttp from the client to the server, and i also don't know about the UTF-8 i just choosed any encoding.

            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