ReadXML retrieving ItemArray


A

Art Krumsee

I have an xml document I'm trying to read in to an application using
readxml(). ReadXML appears to have no problem reading the file. If I use
WriteXML() to write a new document, it contains all the data from the
original document. The problem comes when I try to read data out of the
resulting dataset. I can get to all of the columns but one. I don't know
the syntax to get to a field called "body" which appears to be an itemarray
rather than an item. I've played with many different syntactical options to
retrieve this field but every one I try throws an error.

My code looks like this:

Dim drow As DataRow
Dim ds As New DataSet()
ds.Clear()
ds.ReadXml("c:\gbw.xml")
Dim drow2 As DataRow = ds.Tables(0).Rows(0)
'This works
msgbox(drow2("headline"))
'This doesn't
msgbox(drow2("body")

The XML looks like this:

<?xml version="1.0" encoding="UTF-8" ?>
- <news>
- <story>
<newsid>2584</newsid>
<headline>Auction fails to aid scrambling Cartoon Museum</headline>
<subhead />
<byline1>Erika Gimenes</byline1>
<bytitle1>Hollywood.com Staff</bytitle1>
<byline2 />
<bytitle2 />

<newsurl>http://www.hollywood.com/news/topstories/05-20-01/html/1-1.html</ne
wsurl>
- <body>
<P>New York, May 20, 2001 -- A 1928 six-page, 36-panel storyboard for the
animated Mickey Mouse short "Plane Crazy" failed to sell at auction on
Saturday, leaving the Museum of Cartoon Art in Boca Raton, Fla., scrambling
in debt. The drawing was estimated to be worth more than $3 million.</P>
<P />
<P>The auction, held by the auction house Guernsey's at the New York
Historical Society, was held to raise money to pay off a $2 million debt and
set up an endowment for the museum.</P>
<P />
<P>In addition to Disney favorites, the auction contained original comic
strips from the New York Daily News and the last "Cathy" comic strip of the
20th century, the paper reported.</P>
<P />
<P>The idea for the auction came from the museum's officials, who found
themselves unable to pay about $1 million in mortgage payments. More than
600 items, some donated and some coming from the museum's collection of
200,000 drawings, were put on the block.</P>
<P />
<P>But the Walt Disney drawing failed to bring in a minimum bid of
$800,000 and other cartoons were sold for less than the asking price.</P>
<P />
<P>Bidding for the storyboard started at $400,000 and reached $800,000,
but the sale was put on hold because the credibility of the online bidder
could not be established, Arlan Ettinger, president of Guernsey's, told the
Associated Press.</P>
<P />
<P>Ettinger also said Guernsey's was trying to contact the person who made
the second-highest bid, $700,000. He lamented the fact that despite heavy
promotion of the event, the bids were very low.</P>
<P />
</body>
</story>
- <story>
 
Ad

Advertisements

W

William Ryan

I'd iterate through the Columns using the Numeric Indices instead of the
alias....for instance, try Debug.Writeline(drow2(2).ToSTring & " " &
drow2(3).ToSTring) and see what the names are. In your example, body
doesn't look like a row at all.....and I suspect that's your problem. See
how many Tables are in the Tables collection of that DataSet, I'm guessing
that there are two. Normally from the looks of this you'd have three but
news has no elements.

99% sure this is the source of your problem.

Let me know if this doesn't work.

Cheers,

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

ReadXml 0
ReadXml 0
[.NET1.1] datarow and itemarray 1
ReadXML method 2
WriteXML/ReadXML 2
ReadXML error 2
ReadXml into a DataTable? 5
Slow loading DataRow ItemArray 2

Top