I am using log4net to write to a file rather than the console. Otherwise it
is the example from the book.
while(x.Read())
{
// log.Debug(("Name equals: " + x.Name + " string
value: " + x.ReadString() )) ;
switch (x.NodeType)
{
case XmlNodeType.Element:
log.Debug("Element: " + x.Name);
if (x.HasAttributes)
{
for(int i = 0; i <
x.AttributeCount; i++)
{
log.Debug(string.Format("attribute number
{0}\tvalue={1}",i,x.GetAttribute(i)));
}
}
log.Debug("Element ReadString: " +
x.ReadString()) ;
break;
case XmlNodeType.Text:
//Console.Write(x.Value);
log.Debug("xmlNodetype: " +
x.ReadString());
break;
case XmlNodeType.CDATA:
//Console.Write(x.Value);
log.Debug("CData: " + x.ReadString());
break;
case XmlNodeType.ProcessingInstruction:
//Console.Write("<?{0} {1}?>", x.Name,
x.Value);
log.Debug("Processing Instructions: " +
x.Name + "" + x.ReadString());
break;
case XmlNodeType.Comment:
//Console.Write("<!--{0}-->", x.Value);
log.Debug("Comment: " + x.ReadString());
break;
case XmlNodeType.XmlDeclaration:
//Console.Write("<?xml version='1.0'?>");
log.Debug("xmlDeclaration " );
break;
case XmlNodeType.Document: break; case
XmlNodeType.EndElement:
//Console.Write("</{0}>", x.Name);
log.Debug("Document: " + x.ReadString());
break;
}
[quoted text, click to view] "swapna guddanti [MSFT]" wrote:
> could you post the while loop code that you are using.
>
> thanks,
> swapna
>
> "adhag" <adhag@discussions.microsoft.com> wrote in message
> news:2C27E279-6B82-4EBA-82A6-8489293B1A42@microsoft.com...
> > Hi
> >
> > I am trying to parse through a large file in pieces using the
> xmlNodeReader.
> > I only need it to be forward only and performance is the key but I am
> having
> > a problem trying to get all the information out of my xml file.
> >
> > For arguments sake my sample xml file looks like this
> > <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
> > <row value="123">
> > <errorcol e_w_flag="e" value="10003" col="5"/>
> >
> > <cd>3391214</cd>
> > <cd>M.A. Weatherbie & Co., Inc. - Spec Growth 2</cd>
> > <cd>3.03</cd>
> > <cd> </cd>
> > <cd>10/26/2005</cd>
> > <cd>USD</cd>
> > <cd>PORT</cd>
> > <cd>Q</cd>
> > <cd> </cd>
> > <cd> </cd>
> > </row>
> >
> > If I try to read this the errcol tag is not read. It goes directly from
> the
> > row to the cd tags. Any thoughts? I am doing a simple while reader.read
> > which is working and using a switch to interrogate the elements. I have
> > some suspicions but could use some real help.
> >
> > Thanks,
> > Robin
>
>