I have som XML like this:
<root>
<Course CourseCode="id1 ">
<Teacher Name="Some name"/>
<Title Titlde="Dansk Titel 1"/>
<Title Title="English Title 1"/>
<Location Place="Some place"/>
</Course>
<Course CourseCode="id2 ">
<Teacher Name="Some name"/>
<Title Title="Dansk Titel 2"/>
<Title Title="English Title 2"/>
<Location Place="Some place"/>
</Course>
</root>
I run through this data using an XmlTextReader, but I have problems
with accessing the values the correct way.
I would like the run-through to return a piece of SQL-text like
INSERT INTO Table1 (f1,f2,f3) VALUES ('id1','Dansk Titel 1','English Title 1');
INSERT INTO Table1 (f1,f2,f3) VALUES ('id2','Dansk Titel 2','English Title 2');
to later upload to a database (MySql).
I know that XmlTextReader is a kind of SAX-reader for forward-only
parsing of XML-data, but how do I tweak it to return me the
correct values?
My Existing (test)code is
string s = "";
while (xtr.Read()) {
switch(xtr.Name ) {
case "Course":
s += xtr.GetAttribut e("CourseCode ") + ",";
break;
case "Title":
s += xtr.GetAttribut e("Title") + ",";
break;
default:
break;
}
}
But it doesn't give me the correct data - and I cannot seem to merge it
correctly with the SQL-text.
Can you guys help me out here?
:o)
Thanks,
--
Jesper Stocholm - http://stocholm.dk
The Web submission form is the preferred procedure. However, if you don't
have access to the Internet you may send your submission by e-mail.
(Newsletter from 9th Conference on Reliable Software Technologies)