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. XML / XSL
  4. Reading XML

Reading XML

Scheduled Pinned Locked Moved XML / XSL
xmlquestioncsharpdatabasedebugging
2 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.
  • M Offline
    M Offline
    M_Aurelius
    wrote on last edited by
    #1

    I orginally posted this in the C# forum as I did not notice there was a xml forum... :-D I am trying to read an xml file into a dataset and have been met with nothing but problems. The xml file is in the following format: <?xml version="1.0"?> <Catalog xmlns:dt="dt"> <Rec> <ITEM dt:dt="string"></ITEM> <QTY dt:dt="string">1</QTY> <SUB dt:dt="string"></SUB> <CATALOG dt:dt="string">ABC123</CATALOG> </Rec> </Catalog> I have tried this code in C#: Dataset ds = new DataSet("Test"); ds.ReadXML(OFD.FileName); When I set a breakpoint just after this code and examine ds, all have is a table called "Rec" and one column called "Rec_Id", clearly this is not what I want!! Someone else has tried this and gets finds that ds has changed from "Test" to "Catalog", which is believed to have been picked up from the xml file. Expanding the Tables node reveals have 5 tables: [0] Rec [1] ITEM [2] QTY [3] SUB [4] CATALOG I think this can be done by specifing a schema, but I do not know how you do this whilst reading into a dataset nor do I know enough about schemas to know what to specify where!! If I remove the dt:dt="String" datatypes then everything is fine. I do not want to manually do this so if this is the only way then how can I do it programatically? I need an automated solution. Can anyone help? Thanks

    L 1 Reply Last reply
    0
    • M M_Aurelius

      I orginally posted this in the C# forum as I did not notice there was a xml forum... :-D I am trying to read an xml file into a dataset and have been met with nothing but problems. The xml file is in the following format: <?xml version="1.0"?> <Catalog xmlns:dt="dt"> <Rec> <ITEM dt:dt="string"></ITEM> <QTY dt:dt="string">1</QTY> <SUB dt:dt="string"></SUB> <CATALOG dt:dt="string">ABC123</CATALOG> </Rec> </Catalog> I have tried this code in C#: Dataset ds = new DataSet("Test"); ds.ReadXML(OFD.FileName); When I set a breakpoint just after this code and examine ds, all have is a table called "Rec" and one column called "Rec_Id", clearly this is not what I want!! Someone else has tried this and gets finds that ds has changed from "Test" to "Catalog", which is believed to have been picked up from the xml file. Expanding the Tables node reveals have 5 tables: [0] Rec [1] ITEM [2] QTY [3] SUB [4] CATALOG I think this can be done by specifing a schema, but I do not know how you do this whilst reading into a dataset nor do I know enough about schemas to know what to specify where!! If I remove the dt:dt="String" datatypes then everything is fine. I do not want to manually do this so if this is the only way then how can I do it programatically? I need an automated solution. Can anyone help? Thanks

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      XSLT would be overkill for this.. maybe just iterate over everything and delete all dt:dt attributes?

      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