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. Validating XML Schema

Validating XML Schema

Scheduled Pinned Locked Moved C#
xmlquestiondatabasehelp
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.
  • R Offline
    R Offline
    RichardInToronto
    wrote on last edited by
    #1

    Hi, By calling Dataset.WriteXml, my code produces XML as listed below. The user can also load the XML file, and I will use Dataset.ReadXML to do this. Preferably before calling that method, I would like to validate the schema of the XML to ensure that it has the same structure as an XML file produced by WriteXml. How can I do that? At present, I am loading the XML file and writing code like this: ValidXml = (LoadedOk) & (dsKeysAndValues.Tables[dsnKeysAndValues].Columns[KeyGroup] != null) & (dsKeysAndValues.Tables[dsnKeysAndValues].Columns[ValueGroup] != null) ; The code not only doesn’t work, but it also doesn’t seem elegant – if the XML file is large, it will take time just to load the file, before I can validate it. How can I validate the schema of XML to ensure that it matches what I am expecting? Thanks for your help, pointers, and time! Richard The mystery is out there – in the XML-Files (X-files music follows…) XML produced using WriteXml: K1 V9999

    S 1 Reply Last reply
    0
    • R RichardInToronto

      Hi, By calling Dataset.WriteXml, my code produces XML as listed below. The user can also load the XML file, and I will use Dataset.ReadXML to do this. Preferably before calling that method, I would like to validate the schema of the XML to ensure that it has the same structure as an XML file produced by WriteXml. How can I do that? At present, I am loading the XML file and writing code like this: ValidXml = (LoadedOk) & (dsKeysAndValues.Tables[dsnKeysAndValues].Columns[KeyGroup] != null) & (dsKeysAndValues.Tables[dsnKeysAndValues].Columns[ValueGroup] != null) ; The code not only doesn’t work, but it also doesn’t seem elegant – if the XML file is large, it will take time just to load the file, before I can validate it. How can I validate the schema of XML to ensure that it matches what I am expecting? Thanks for your help, pointers, and time! Richard The mystery is out there – in the XML-Files (X-files music follows…) XML produced using WriteXml: K1 V9999

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      Take a look at the XmlValidatingReader class. It's obsolete in .NET 2.0 but the MSDN topic also provides links to topics that present you what to use instead.


      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

      www.troschuetz.de

      R 1 Reply Last reply
      0
      • S Stefan Troschuetz

        Take a look at the XmlValidatingReader class. It's obsolete in .NET 2.0 but the MSDN topic also provides links to topics that present you what to use instead.


        "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

        www.troschuetz.de

        R Offline
        R Offline
        RichardInToronto
        wrote on last edited by
        #3

        Hi Stefan, Thanks for your help. Richard

        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