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. C#
  4. Read non standard conformant XML

Read non standard conformant XML

Scheduled Pinned Locked Moved C#
questionxmlhelptutorial
4 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.
  • T Offline
    T Offline
    tommazzo
    wrote on last edited by
    #1

    Hi! I want to read an XML file, which is not completely standard conformant. To be more precise some of its nodes contain text with special characters (see the example below). <RootElement> <ConformantNode>Hello</ConformantNode> <NonConformantNode>You & me</NonConformantNode> </RootElement> As you can see "NonConformantNode" contains an & char in its text, which always makes System.Xml.XmlReader throw an exception. How can I read the content of this document, in other words, how can I read an XML document without automatic character decoding? Thanks for your help in advance! P.S.: I already tried setting XmlReaderSettings.CheckCharacters to false, but this doesn't do the trick. -- modified at 8:01 Saturday 17th September, 2005

    G T 2 Replies Last reply
    0
    • T tommazzo

      Hi! I want to read an XML file, which is not completely standard conformant. To be more precise some of its nodes contain text with special characters (see the example below). <RootElement> <ConformantNode>Hello</ConformantNode> <NonConformantNode>You & me</NonConformantNode> </RootElement> As you can see "NonConformantNode" contains an & char in its text, which always makes System.Xml.XmlReader throw an exception. How can I read the content of this document, in other words, how can I read an XML document without automatic character decoding? Thanks for your help in advance! P.S.: I already tried setting XmlReaderSettings.CheckCharacters to false, but this doesn't do the trick. -- modified at 8:01 Saturday 17th September, 2005

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      One way could be to read the file into a string, replace the illegal characters with their legal code, and then read the string into an xml document. --- b { font-weight: normal; }

      T 1 Reply Last reply
      0
      • G Guffa

        One way could be to read the file into a string, replace the illegal characters with their legal code, and then read the string into an xml document. --- b { font-weight: normal; }

        T Offline
        T Offline
        tommazzo
        wrote on last edited by
        #3

        This could of course be an approach, but as some of the files are quite big, performance would suffer a lot. Isn't there a way that I can configure XmlReader to forget about any kind of character encoding?

        1 Reply Last reply
        0
        • T tommazzo

          Hi! I want to read an XML file, which is not completely standard conformant. To be more precise some of its nodes contain text with special characters (see the example below). <RootElement> <ConformantNode>Hello</ConformantNode> <NonConformantNode>You & me</NonConformantNode> </RootElement> As you can see "NonConformantNode" contains an & char in its text, which always makes System.Xml.XmlReader throw an exception. How can I read the content of this document, in other words, how can I read an XML document without automatic character decoding? Thanks for your help in advance! P.S.: I already tried setting XmlReaderSettings.CheckCharacters to false, but this doesn't do the trick. -- modified at 8:01 Saturday 17th September, 2005

          T Offline
          T Offline
          tommazzo
          wrote on last edited by
          #4

          Has anybody got an idea? It's quite urgent.

          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