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. Web Development
  3. ASP.NET
  4. special charcters in XML, in ASP.net???

special charcters in XML, in ASP.net???

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-netxmljson
6 Posts 3 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.
  • M Offline
    M Offline
    mittalpa
    wrote on last edited by
    #1

    Hi, I am trying to read an XML file using XmlDocument.LoadXml() function, in ASP.net. This xml has data which contains special characters like ampersand (&). But it fails saying "An error occurred while parsing EntityName. Line 1, position 31." How can I make this xml string valid before passing to LoadXML() function. Please advise. Thanks Pankaj Pankaj Follow your goals, Means will follow you ---Gandhi---

    M 1 Reply Last reply
    0
    • M mittalpa

      Hi, I am trying to read an XML file using XmlDocument.LoadXml() function, in ASP.net. This xml has data which contains special characters like ampersand (&). But it fails saying "An error occurred while parsing EntityName. Line 1, position 31." How can I make this xml string valid before passing to LoadXML() function. Please advise. Thanks Pankaj Pankaj Follow your goals, Means will follow you ---Gandhi---

      M Offline
      M Offline
      Mark Smithson
      wrote on last edited by
      #2

      If the xml file contains these special characters, it is not valid xml. You will need to replace these characters with their escaped verions. Have a look in MSDN or on www.w3c.org for the complete list. Some I can remember are; & - & " - " < - < > - >

      M M J 3 Replies Last reply
      0
      • M Mark Smithson

        If the xml file contains these special characters, it is not valid xml. You will need to replace these characters with their escaped verions. Have a look in MSDN or on www.w3c.org for the complete list. Some I can remember are; & - & " - " < - < > - >

        M Offline
        M Offline
        Mark Smithson
        wrote on last edited by
        #3

        Hmm. CodeProject has rendered the escaped characters ... Try again & - & " - " < - < > - >

        1 Reply Last reply
        0
        • M Mark Smithson

          If the xml file contains these special characters, it is not valid xml. You will need to replace these characters with their escaped verions. Have a look in MSDN or on www.w3c.org for the complete list. Some I can remember are; & - & " - " < - < > - >

          M Offline
          M Offline
          mittalpa
          wrote on last edited by
          #4

          Thanks for the reply. Actually, I found the solution. All we need to do is add following as the first line in xml: This will take care of it. :) Pankaj Follow your goals, Means will follow you ---Gandhi---

          M 1 Reply Last reply
          0
          • M mittalpa

            Thanks for the reply. Actually, I found the solution. All we need to do is add following as the first line in xml: This will take care of it. :) Pankaj Follow your goals, Means will follow you ---Gandhi---

            M Offline
            M Offline
            mittalpa
            wrote on last edited by
            #5

            the line is: ~~Pankaj~~ Follow your goals, Means will follow you ---Gandhi---

            1 Reply Last reply
            0
            • M Mark Smithson

              If the xml file contains these special characters, it is not valid xml. You will need to replace these characters with their escaped verions. Have a look in MSDN or on www.w3c.org for the complete list. Some I can remember are; & - & " - " < - < > - >

              J Offline
              J Offline
              J Dunlap
              wrote on last edited by
              #6

              Also, you can do any ASCII char: &#--; where -- is the ASCII character code for the character you want.

              "Blessed are the peacemakers, for they shall be called sons of God." - Jesus
              "You must be the change you wish to see in the world." - Mahatma Gandhi

              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