nbsp; switch (navigator.NodeType)
{
case XmlNodeType.ProcessingInstruction:
Format (navigator, "ProcessingInstruction");
break;
case XmlNodeType.DocumentType:
Format (navigator, "DocumentType");
break;
case XmlNodeType.Document:
Format (navigator, "Document");
break;
case XmlNodeType.Comment:
Format (navigator, "Comment");
break;
case XmlNodeType.Element:
Format (navigator, "Element");
break;
case XmlNodeType.Text:
Format (navigator, "Text");
break;
case XmlNodeType.Whitespace:
Format (navigator, "Whitespace");
break;
}
}
outputQ.Append(" ");
}
// Format the output
private void Format (XmlNavigator navigator, String NodeType)
{
String value = String.Empty;
String name = String.Empty;
if (navigator.HasChildren)
{
name = navigator.Name;
navigator.MoveToFirstChild();
if (navigator.HasValue)
{
value = navigator.Value;
}
}
else
{
if (navigator.HasValue)
{
value = navigator.Value;
name = navigator.Name;
}
}
outputQ.Append(NodeType + "<" + name + ">" + value);
outputQ.Append(" ");
}
// ********************************** XmlReader *****************************
public void ShowDocument ()
{
outputXml = new StringBuilder();
XmlTextReader reader = new XmlTextReader (FileLabel.Text);
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.ProcessingInstruction:
Format (reader, "ProcessingInstruction");
break;
case XmlNodeType.DocumentType:
Format (reader, "DocumentType");
break;
case XmlNodeType.Comment:
Format (reader, "Comment");
break;
case XmlNodeType.Element:
Format (reader, "Element");
break;
case XmlNodeType.Text:
Format (reader, "Text");
break;
case XmlNodeType.Whitespace:
break;
}
}
TextBox3.Text = outputXml.ToString();
}
protected void Format(XmlReader reader, String NodeType)
{
// Format the output
for (int i=0; i < reader.Depth; i++)
{
outputXml.Append(' ');
}
outputXml.Append(reader.Prefix + NodeType + "<" + reader.Name + ">" + reader.Value);
// Display the attributes values for the current node
if (reader.HasAttributes)
{
outputXml.Append(" Attributes:");
for (int j=0; j < reader.AttributeCount; j++)
{
outputXml.Append(reader[j]);
}
}
outputXml.Append(" ");
}
/// ************************* DOM *********************************
protected void ShowDocument(XmlNode node)
{
if (node != null)
Format (node);
if (node.HasChildNodes)
{
node = node.FirstChild;
&nb
{
case XmlNodeType.ProcessingInstruction:
Format (navigator, "ProcessingInstruction");
break;
case XmlNodeType.DocumentType:
Format (navigator, "DocumentType");
break;
case XmlNodeType.Document:
Format (navigator, "Document");
break;
case XmlNodeType.Comment:
Format (navigator, "Comment");
break;
case XmlNodeType.Element:
Format (navigator, "Element");
break;
case XmlNodeType.Text:
Format (navigator, "Text");
break;
case XmlNodeType.Whitespace:
Format (navigator, "Whitespace");
break;
}
}
outputQ.Append(" ");
}
// Format the output
private void Format (XmlNavigator navigator, String NodeType)
{
String value = String.Empty;
String name = String.Empty;
if (navigator.HasChildren)
{
name = navigator.Name;
navigator.MoveToFirstChild();
if (navigator.HasValue)
{
value = navigator.Value;
}
}
else
{
if (navigator.HasValue)
{
value = navigator.Value;
name = navigator.Name;
}
}
outputQ.Append(NodeType + "<" + name + ">" + value);
outputQ.Append(" ");
}
// ********************************** XmlReader *****************************
public void ShowDocument ()
{
outputXml = new StringBuilder();
XmlTextReader reader = new XmlTextReader (FileLabel.Text);
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.ProcessingInstruction:
Format (reader, "ProcessingInstruction");
break;
case XmlNodeType.DocumentType:
Format (reader, "DocumentType");
break;
case XmlNodeType.Comment:
Format (reader, "Comment");
break;
case XmlNodeType.Element:
Format (reader, "Element");
break;
case XmlNodeType.Text:
Format (reader, "Text");
break;
case XmlNodeType.Whitespace:
break;
}
}
TextBox3.Text = outputXml.ToString();
}
protected void Format(XmlReader reader, String NodeType)
{
// Format the output
for (int i=0; i < reader.Depth; i++)
{
outputXml.Append(' ');
}
outputXml.Append(reader.Prefix + NodeType + "<" + reader.Name + ">" + reader.Value);
// Display the attributes values for the current node
if (reader.HasAttributes)
{
outputXml.Append(" Attributes:");
for (int j=0; j < reader.AttributeCount; j++)
{
outputXml.Append(reader[j]);
}
}
outputXml.Append(" ");
}
/// ************************* DOM *********************************
protected void ShowDocument(XmlNode node)
{
if (node != null)
Format (node);
if (node.HasChildNodes)
{
node = node.FirstChild;
&nb