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. C#
  4. Error in reading xml...

Error in reading xml...

Scheduled Pinned Locked Moved C#
helpcsharpxml
7 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.
  • V Offline
    V Offline
    vinu netguy
    wrote on last edited by
    #1

    Hi buddies, I had an xml like "Joe&&&&&&&redroom" when i am tried with the code in c# as, 1. tmp_Message = "Joe&&&&&&&&&&&redroom"; XmlDocument xXD = new XmlDocument(); xXD.LoadXml(tmp_Message); it is throwing error. 2. can i get any function to check, if a given string is a proper xml or not in C# please..... help me ..!!!! in solving this error. regards, vinu

    M 1 Reply Last reply
    0
    • V vinu netguy

      Hi buddies, I had an xml like "Joe&&&&&&&redroom" when i am tried with the code in c# as, 1. tmp_Message = "Joe&&&&&&&&&&&redroom"; XmlDocument xXD = new XmlDocument(); xXD.LoadXml(tmp_Message); it is throwing error. 2. can i get any function to check, if a given string is a proper xml or not in C# please..... help me ..!!!! in solving this error. regards, vinu

      M Offline
      M Offline
      mav northwind
      wrote on last edited by
      #2

      Of course is XmlDocument.LoadXml() throwing an exception, because of all the ampersands in your string. They must be escaped as & Using LoadXml() in a try/catch is a way to check for proper XML. Regards, mav

      V 2 Replies Last reply
      0
      • M mav northwind

        Of course is XmlDocument.LoadXml() throwing an exception, because of all the ampersands in your string. They must be escaped as & Using LoadXml() in a try/catch is a way to check for proper XML. Regards, mav

        V Offline
        V Offline
        vinu netguy
        wrote on last edited by
        #3

        hi mav, it is not throwing error if i escaped with a single & if i use like &&&&&&&&&& then it is throwing error. i think its not a good way, if i use try/catch to check. please help with a solution. vinu

        1 Reply Last reply
        0
        • M mav northwind

          Of course is XmlDocument.LoadXml() throwing an exception, because of all the ampersands in your string. They must be escaped as & Using LoadXml() in a try/catch is a way to check for proper XML. Regards, mav

          V Offline
          V Offline
          vinu netguy
          wrote on last edited by
          #4

          hi mav, it is not throwing error if i escaped with a single & if i use like &&&&&&&&&& then it is throwing error. i think its not a good way, if i use try/catch to check. please help with a solution. vinu

          M 1 Reply Last reply
          0
          • V vinu netguy

            hi mav, it is not throwing error if i escaped with a single & if i use like &&&&&&&&&& then it is throwing error. i think its not a good way, if i use try/catch to check. please help with a solution. vinu

            M Offline
            M Offline
            mav northwind
            wrote on last edited by
            #5

            Of course you have to escape every & as &. If you do this, the xml string is correct and no exception is thrown. AFAIK there's no ValidateXml method available, so trying to load the string and looking for an XmlException seems to be a reasonable way. Regards, mav

            V 1 Reply Last reply
            0
            • M mav northwind

              Of course you have to escape every & as &. If you do this, the xml string is correct and no exception is thrown. AFAIK there's no ValidateXml method available, so trying to load the string and looking for an XmlException seems to be a reasonable way. Regards, mav

              V Offline
              V Offline
              vinu netguy
              wrote on last edited by
              #6

              Thanks mav. Regards, Vinu

              V 1 Reply Last reply
              0
              • V vinu netguy

                Thanks mav. Regards, Vinu

                V Offline
                V Offline
                vinu netguy
                wrote on last edited by
                #7

                Thanks very much. its working now......:) Vinu

                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