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. XML Loading Problem

XML Loading Problem

Scheduled Pinned Locked Moved C#
helpquestionvisual-studioxml
4 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.
  • N Offline
    N Offline
    Nick Parker
    wrote on last edited by
    #1

    Does anyone have any clues as to why I would get an "Unhandled Exception of type 'System.Xml.XmlException'" with the following code sniplet? It just says "Additional information: System Error". What is weird is that the error occurs on the red line and does not throw an exception based on my code (It comes from the IDE). Am I missing something blatant here?

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.LoadXml("XMLTree.xml");
    try
    {
    XmlNodeList xmlnodeList = xmlDoc.SelectNodes("categories");
    foreach(XmlNode x in xmlnodeList)
    {
    MessageBox.Show(x.InnerText);

    }
    

    }
    catch(System.Xml.XmlException e)
    {
    MessageBox.Show(e.Message + "\n\n" + e.StackTrace);
    }

    -Nick Parker

    P C 2 Replies Last reply
    0
    • N Nick Parker

      Does anyone have any clues as to why I would get an "Unhandled Exception of type 'System.Xml.XmlException'" with the following code sniplet? It just says "Additional information: System Error". What is weird is that the error occurs on the red line and does not throw an exception based on my code (It comes from the IDE). Am I missing something blatant here?

      XmlDocument xmlDoc = new XmlDocument();
      xmlDoc.LoadXml("XMLTree.xml");
      try
      {
      XmlNodeList xmlnodeList = xmlDoc.SelectNodes("categories");
      foreach(XmlNode x in xmlnodeList)
      {
      MessageBox.Show(x.InnerText);

      }
      

      }
      catch(System.Xml.XmlException e)
      {
      MessageBox.Show(e.Message + "\n\n" + e.StackTrace);
      }

      -Nick Parker

      P Offline
      P Offline
      Philip Fitzsimons
      wrote on last edited by
      #2

      your mistake is: xmlDoc.LoadXml("XMLTree.xml"); you want xmlDoc.Load("XMLTree.xml"); currently your code thinks that "XMLTre.xml" is xml source ;P


      "When the only tool you have is a hammer, a sore thumb you will have."

      N 1 Reply Last reply
      0
      • N Nick Parker

        Does anyone have any clues as to why I would get an "Unhandled Exception of type 'System.Xml.XmlException'" with the following code sniplet? It just says "Additional information: System Error". What is weird is that the error occurs on the red line and does not throw an exception based on my code (It comes from the IDE). Am I missing something blatant here?

        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.LoadXml("XMLTree.xml");
        try
        {
        XmlNodeList xmlnodeList = xmlDoc.SelectNodes("categories");
        foreach(XmlNode x in xmlnodeList)
        {
        MessageBox.Show(x.InnerText);

        }
        

        }
        catch(System.Xml.XmlException e)
        {
        MessageBox.Show(e.Message + "\n\n" + e.StackTrace);
        }

        -Nick Parker

        C Offline
        C Offline
        cdehelean
        wrote on last edited by
        #3

        My guess: it has nothing to do with the categories XPath you gave. Your xml document is malformed and the parser gets confused in parsing it. All I need is a roadmap and then I might be able to find a clue.

        1 Reply Last reply
        0
        • P Philip Fitzsimons

          your mistake is: xmlDoc.LoadXml("XMLTree.xml"); you want xmlDoc.Load("XMLTree.xml"); currently your code thinks that "XMLTre.xml" is xml source ;P


          "When the only tool you have is a hammer, a sore thumb you will have."

          N Offline
          N Offline
          Nick Parker
          wrote on last edited by
          #4

          Philip Fitzsimons wrote: currently your code thinks that "XMLTre.xml" is xml source :-O Thanks, that did it. :) -Nick Parker

          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