Xml Woe
<element />
Instead of:
<element> </element>
It messes me up, because it's only picked up as an element, and no element end.
Here's the code I'm using:
langReader is System.Xml.XmlReader
fParseLog is just a form with a log on it
while ( langReader.Read( ) )
{
// This variable stores what each line in the log window is
sWindowString = "";
// Use a switch flow-control to determine the type of node that we are currently dealing with
switch ( langReader.NodeType )
{
case XmlNodeType.Element:
// Switch the current element
iCurLevel++;
sCurElement[iCurLevel] = langReader.Name;
fParseLog.logEvent( "\r\n" + CreateTabs( iCurLevel ) + "<" + langReader.Name + "> " );
break;
case XmlNodeType.EndElement:
// Just for debug purposes.
fParseLog.logEvent( "\r\n" + CreateTabs( iCurLevel ) + "</" + langReader.Name + ">" );
if ( langReader.Name == sCurElement[ iCurLevel ] )
{
// We've cloesed an element; Close the highest level element
iCurLevel--;
}
break;
case XmlNodeType.Text:
// We have a node other then an element, so switch around
// to see what we are dealing with
fParseLog.logEvent( " " + langReader.Value );
switch ( sCurElement[ iCurLevel ] )
{
case "comment":
// Add the text in between the element tags to
// the comments of the temp language
langTemp.addComment( langReader.Value );
break;
case "function":
// We have a function. Add the text in between
// the element tags.
langTemp.addFunction( langReader.Value );
break;
}
break;
}
if ( langReader.HasAttributes )
{
while ( langReader.MoveToNextAttribute( ) )
{
switch ( sCurElement[ iCurLevel ] )
{
case "language":
if ( langReader.Name == "title" )
{
// It's the title
sLangTitle = langReader.Value;
fParseLog.changeTitle( langReader.Value );
langTemp.setTitle( sLangTitle );
}
break;
}
fParseLog.logEvent( "Attribute: " + langReader.Name + " = " + langReader.Value );
}
// Move the reader back to the element node.
langReader.MoveToElement( );
}
// Log event
//fParseLog.logEvent( langReader.Value.ToString() );
}
Any help would be great :)

