Click here to Skip to main content
15,920,053 members
Home / Discussions / C#
   

C#

 
QuestionC# on Linux Pin
loscarlitos16-Jan-07 14:32
loscarlitos16-Jan-07 14:32 
AnswerRe: C# on Linux Pin
Christian Graus16-Jan-07 14:57
protectorChristian Graus16-Jan-07 14:57 
AnswerRe: C# on Linux Pin
User 665816-Jan-07 15:15
User 665816-Jan-07 15:15 
GeneralRe: C# on Linux Pin
Seishin#16-Jan-07 22:30
Seishin#16-Jan-07 22:30 
AnswerRe: C# on Linux Pin
Darren D17-Jan-07 2:55
Darren D17-Jan-07 2:55 
GeneralRe: C# on Linux Pin
loscarlitos17-Jan-07 12:42
loscarlitos17-Jan-07 12:42 
GeneralRe: C# on Linux Pin
Darren D18-Jan-07 2:45
Darren D18-Jan-07 2:45 
QuestionReading Xml using XmlReader Pin
Patrick Klug16-Jan-07 13:07
Patrick Klug16-Jan-07 13:07 
Hi folks,

I am a bit puzzled how to use the System.Xml.XmlReader to read data D'Oh! | :doh:

To give a simple example I want to read a Xml file like this:

<Person>
<Name>Peter</Name>
<Sirname>Alen</Sirname>
</Person>

in a object with the same properties...

what I did was something like this:

...
Person person = new Person();
while (reader.Read())
{
if (reader.Name=="Name")
{
person.Name = reader.ReadElementContentAsString();
}
if (reader.Sirname == "Sirname")
{
person.Sirname = reader.ReadElementContentAsString();
}
}
...

of course simplified, the real thing is a bit more complicated...
this does work if the Xml is exactly the same way I outlined above but if, for example, the Name tag comes after the Sirname tag the code doesn't work anymore because the reader.ReadElementContentAsString() is advancing the reader and the reader.Read() as well thus one element is simply not handled by the code in the while loop...

I hope I explained it well enough Sniff | :^)

any suggestions welcome!
TIA
Pakl
AnswerRe: Reading Xml using XmlReader Pin
Christian Graus16-Jan-07 13:36
protectorChristian Graus16-Jan-07 13:36 
GeneralRe: Reading Xml using XmlReader Pin
Patrick Klug16-Jan-07 14:49
Patrick Klug16-Jan-07 14:49 
GeneralRe: Reading Xml using XmlReader Pin
Christian Graus16-Jan-07 14:57
protectorChristian Graus16-Jan-07 14:57 
GeneralRe: Reading Xml using XmlReader Pin
Patrick Klug16-Jan-07 15:15
Patrick Klug16-Jan-07 15:15 
GeneralRe: Reading Xml using XmlReader Pin
Christian Graus16-Jan-07 16:32
protectorChristian Graus16-Jan-07 16:32 
GeneralRe: Reading Xml using XmlReader Pin
Patrick Klug16-Jan-07 17:02
Patrick Klug16-Jan-07 17:02 
GeneralRe: Reading Xml using XmlReader Pin
Christian Graus16-Jan-07 19:42
protectorChristian Graus16-Jan-07 19:42 
QuestionGDI+ Question Pin
Mike Hankey16-Jan-07 12:30
mveMike Hankey16-Jan-07 12:30 
QuestionPrinting Pin
Christopher Thornburg16-Jan-07 11:39
Christopher Thornburg16-Jan-07 11:39 
AnswerRe: Printing Pin
gnadeem16-Jan-07 13:00
gnadeem16-Jan-07 13:00 
QuestionC# UI Control to crop images Pin
njoaopg16-Jan-07 11:22
njoaopg16-Jan-07 11:22 
AnswerRe: C# UI Control to crop images Pin
Christian Graus16-Jan-07 13:03
protectorChristian Graus16-Jan-07 13:03 
GeneralRe: C# UI Control to crop images Pin
electriac16-Jan-07 23:58
electriac16-Jan-07 23:58 
GeneralRe: C# UI Control to crop images Pin
Christian Graus17-Jan-07 0:01
protectorChristian Graus17-Jan-07 0:01 
GeneralRe: C# UI Control to crop images Pin
electriac17-Jan-07 5:20
electriac17-Jan-07 5:20 
GeneralRe: C# UI Control to crop images Pin
electriac17-Jan-07 5:21
electriac17-Jan-07 5:21 
GeneralRe: C# UI Control to crop images Pin
njoaopg17-Jan-07 5:35
njoaopg17-Jan-07 5:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.