Incorrect work of Dataset deserialized from XML


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Incorrect work of Dataset deserialized from XML

Hybrid View

  1. #1
    Join Date
    Jul 2004
    Posts
    20

    Question Incorrect work of Dataset deserialized from XML

    Code:
    string stmp = "\n<rs:data ItemCount=\"6\" xmlns:rs=\"urn:schemas-microsoft-com:rowset\">\n   <z:row _x041a__x043b__x0438__x0435__x043d__x0442___x043a__x043e__x0434_=\"16440042770нс\" _x0424__x0438__x043b__x0438__x0430__x043b___x041a__x043e__x0434_=\"20706\" _x041a__x043e__x0434_=\"3049\" _x041d__x0430__x0437__x0432__x0430__x043d__x0438__x0435_=\"Татнефть У*С\" BdcIdentity=\"__bg01003300030043009300\" xmlns:z=\"#RowsetSchema\" />\n   <z:row _x041a__x043b__x0438__x0435__x043d__x0442___x043a__x043e__x0434_=\"16440042770нс\" _x0424__x0438__x043b__x0438__x0430__x043b___x041a__x043e__x0434_=\"20706\" _x041a__x043e__x0434_=\"5328\" _x041d__x0430__x0437__x0432__x0430__x043d__x0438__x0435_=\"*озница\" BdcIdentity=\"__bg01005300330023008300\" xmlns:z=\"#RowsetSchema\" />\n   <z:row _x041a__x043b__x0438__x0435__x043d__x0442___x043a__x043e__x0434_=\"16440042770нс\" _x0424__x0438__x043b__x0438__x0430__x043b___x041a__x043e__x0434_=\"20706\" _x041a__x043e__x0434_=\"5353\" _x041d__x0430__x0437__x0432__x0430__x043d__x0438__x0435_=\"Медуница\" BdcIdentity=\"__bg01005300330053003300\" xmlns:z=\"#RowsetSchema\" />\n   <z:row _x041a__x043b__x0438__x0435__x043d__x0442___x043a__x043e__x0434_=\"16440042770нс\" _x0424__x0438__x043b__x0438__x0430__x043b___x041a__x043e__x0434_=\"20706\" _x041a__x043e__x0434_=\"5357\" _x041d__x0430__x0437__x0432__x0430__x043d__x0438__x0435_=\"Оптовик\" BdcIdentity=\"__bg01005300330053007300\" xmlns:z=\"#RowsetSchema\" />\n   <z:row _x041a__x043b__x0438__x0435__x043d__x0442___x043a__x043e__x0434_=\"16440042770нс\" _x0424__x0438__x043b__x0438__x0430__x043b___x041a__x043e__x0434_=\"20706\" _x041a__x043e__x0434_=\"8372\" _x041d__x0430__x0437__x0432__x0430__x043d__x0438__x0435_=\"Артемьев ИП\" BdcIdentity=\"__bg01008300330073002300\" xmlns:z=\"#RowsetSchema\" />\n   <z:row _x041a__x043b__x0438__x0435__x043d__x0442___x043a__x043e__x0434_=\"16440042770нс\" _x0424__x0438__x043b__x0438__x0430__x043b___x041a__x043e__x0434_=\"20706\" _x041a__x043e__x0434_=\"8620\" _x041d__x0430__x0437__x0432__x0430__x043d__x0438__x0435_=\"Шифа\" BdcIdentity=\"__bg01008300630023000300\" xmlns:z=\"#RowsetSchema\" />\n</rs:data>\n";
                XmlDocument xd = new XmlDocument();
                xd.LoadXml(stmp);
    
                DataSet dsQuery = new DataSet();
                var node = xd.DocumentElement as XmlNode;
                XmlReader reader1 = new XmlNodeReader(node);
                dsQuery.ReadXml(reader1);
    
                var v1 = dsQuery.Tables["row"].Rows[4]["_x041a__x043e__x0434_"];
                var v2 = dsQuery.Tables["row"].Rows[4][dsQuery.Tables["row"].Columns[2].ColumnName];

    The line with v1 throws an exception:

    Column '_x041a__x043e__x0434_' does not belong to table row.


    The line with v2 throws no exception, however it returns an empty value instead of expected integer value. I wonder why it happens and how to force dataset to work with my XML correctly?

  2. #2
    Join Date
    Oct 2008
    Posts
    142

    i wouldnt code a dataset by hand

    hi there,

    use a tool and next copy and paste its xml.
    go to google.com and search for

    create a dataset with a tool

    my best guess is that the dataset designer is your best match.
    it creates typed datasets.
    so, what happens once youve got a dataset the way you want it?
    you convert it to xml.
    search for

    dataset toxml method

    in google or your favorite search engine.
    you can also create a dataset with source code, instead of writing datasets xml by hand.
    once you have your dataset created with source code, use some to xml method.

    i hope this helps,

    tonci korsano

Similar Threads

  1. Incorrect syntax near...
    By geo039 in forum ASP.NET
    Replies: 4
    Last Post: 08-24-2007, 04:15 AM
  2. Replies: 0
    Last Post: 05-14-2007, 12:41 AM
  3. Replies: 0
    Last Post: 04-02-2007, 10:39 AM
  4. Incorrect syntax near '#IND'
    By Mario in forum Database
    Replies: 2
    Last Post: 07-29-2000, 07:45 AM
  5. i need help (incorrect email)
    By ADRIAN HERNANDEZ in forum VB Classic
    Replies: 0
    Last Post: 03-20-2000, 02:43 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center