I have an XML file as below.
<BOOK bnumber="1" bname="Book">
<CHAPTER cnumber="1">
<Sentence vnumber="1">This is the sentence 1.</Sentence>
<Sentence vnumber="2">This is the sentence 2.</Sentence>
<Sentence vnumber="3">This is the sentence 3.</Sentence>
</CHAPTER>
<CHAPTER cnumber="2">
<Sentence vnumber="1">Hello World 1.</Sentence>
<Sentence vnumber="2">Hello World 2.</Sentence>
<Sentence vnumber="3">Hello World 3.</Sentence>
<Sentence vnumber="4">Hello World 4.</Sentence>
</CHAPTER>
<CHAPTER cnumber="3">
<Sentence vnumber="1">Good morning 1.</Sentence>
<Sentence vnumber="2">Good morning 2.</Sentence>
<Sentence vnumber="3">Good morning 3.</Sentence>
</CHAPTER>
</BOOK>
What I want is to collect the attributes of "CHAPTER". The goal is to get
Chapter={"Chapter 1";"Chapter 2","Chapter 3"};
Current I use tradition method,
XmlDocument xdoc = new XmlDocument();
xdoc.Load(@"C:\books.xml"); //load the xml file into our document
XmlNodeList nodes = xdoc.SelectNodes(@"//BOOK/CHAPTER[@cnumber='" + chap
string sentences = "";
foreach(XmlNode node in nodes) {
sentences += node.InnerText + "; ";
}
but I want to use XMLReader because the XML file is big, I don't want to load it in memory.
Thanks for help.
XMLReaderyet?