30.07.2013 Views

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

844 Extensible Markup Language (XML) Chapter 18<br />

45 TabOutput(depth)<br />

46 txtOutput.Text &= "" & _<br />

47 vbCrLf<br />

48<br />

49 ' if empty element, decrease depth<br />

50 If reader.IsEmptyElement Then<br />

51 depth -= 1<br />

52 End If<br />

53<br />

54 Case XmlNodeType.Comment ' if Comment, display it<br />

55 TabOutput(depth)<br />

56 txtOutput.Text &= "" & vbCrLf<br />

58<br />

59 Case XmlNodeType.Text ' if Text, display it<br />

60 TabOutput(depth)<br />

61 txtOutput.Text &= vbTab & reader.Value & vbCrLf<br />

62<br />

63 ' if XML declaration, display it<br />

64 Case XmlNodeType.XmlDeclaration<br />

65 TabOutput(depth)<br />

66 txtOutput.Text &= "" & vbCrLf<br />

68<br />

69 ' if EndElement, display it and decrement depth<br />

70 Case XmlNodeType.EndElement<br />

71 TabOutput(depth)<br />

72 txtOutput.Text &= "/" & _<br />

73 vbCrLf<br />

74<br />

75 depth -= 1<br />

76<br />

77 End Select<br />

78<br />

79 End While<br />

80<br />

81 End Sub ' New<br />

82<br />

83 ' <strong>Visual</strong> Studio .<strong>NET</strong> generated code<br />

84<br />

85 ' insert tabs<br />

86 Private Sub TabOutput(ByVal number As Integer)<br />

87 Dim i As Integer<br />

88<br />

89 For i = 0 To number - 1<br />

90 txtOutput.Text &= vbTab<br />

91 Next<br />

92<br />

93 End Sub ' TabOutput<br />

94<br />

95 End Class ' FrmXmlReaderTest<br />

Fig. 18.7 XmlNodeReader iterates through an XML document (part 2 of 3).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!