EDN Admin
Well-known member
Hello, I have two combobox in a windows form. One is "Book", the other is "Chapter". What I want to is to display the context after I select the item from the drop down box. Now my query has something wrong. Please see my code. Thanks for help.
<div style="color:black; background-color:white
<pre><span style="color:blue private <span style="color:blue void Book_SelectedIndexChanged(<span style="color:blue object sender, EventArgs e)
{
<span style="color:blue string selectedBook = Book.SelectedItem.ToString();
<span style="color:blue string query = <span style="color:blue string.Format(<span style="color:#a31515 "//BIBLEBOOK[@bname=" + selectedBook + <span style="color:#a31515 "]/CHAPTER/@cnumber");
XmlNodeList Chapters = doc.SelectNodes(query);
<span style="color:blue string[] result = <span style="color:blue new <span style="color:blue string[Chapters.Count];
<span style="color:blue for (<span style="color:blue int i = 0; i < Chapters.Count; i++)
{
result = <span style="color:blue string.Concat(Chapters.InnerText);
}
Chapter.Items.AddRange(result);
<span style="color:green //textBox1.Text=
}
<span style="color:blue private <span style="color:blue void Chapter_SelectedIndexChanged(<span style="color:blue object sender, EventArgs e)
{
<span style="color:blue string selectedBook = Book.SelectedItem.ToString();
<span style="color:blue string selectedChapter = Chapter.SelectedItem.ToString();
<span style="color:blue string query = <span style="color:blue string.Format(<span style="color:#a31515 "//BIBLEBOOK[@bname=" + selectedBook + <span style="color:#a31515 "/CHAPTER/@cnumber="+selectedChapter+<span style="color:#a31515 "]");
<span style="color:green //wrong query here
[/code]
<div style="color:black; background-color:white
<pre> XmlNodeList verses = doc.SelectNodes(query);
}
[/code]
The xml file format:
<pre lang="x-xml <?xml version="1.0" encoding="ISO-8859-1" ?>
- <XMLBIBLE biblename="VW-Edition 2010
- <BIBLEBOOK bnumber="1" bname="Genesis
- <CHAPTER cnumber="1
<VERS vnumber="1 In the beginning God created the heavens and the earth.</VERS>
<VERS vnumber="2 And the earth was without form, and void, with darkness on the face of the deep; and the Spirit of God was hovering over the face of the waters.</VERS>
<VERS vnumber="3 Then God said, Let there be light! And there was light.</VERS>
<VERS vnumber="4 And God saw the light, that it was good; and God divided between the light and darkness.</VERS>
<VERS vnumber="5 God called the light, Day; and the darkness He called, Night. Thus, the evening and the morning: Day One.</VERS>
<VERS vnumber="6 Then God said, Let there be a firmament in the midst of the waters, separating the waters from the waters.</VERS>
<VERS vnumber="7 And God made the firmament, and separated the waters which were under the firmament from the waters which were above the firmament: thus.</VERS>
<VERS vnumber="8 And God called the firmament, Heavens. Thus, the evening and the morning: Day Two.</VERS>
<VERS vnumber="9 Then God said, Let the waters under the heavens be gathered together into one place, and let the dry land appear: thus.</VERS>
<VERS vnumber="10 And God called the dry land, Earth; and the gathering together of the waters He called, Seas. And God saw that it was good.</VERS>
<VERS vnumber="11 And God said, Let the earth sprout vegetation, plants yielding seed, and the fruit tree producing fruit according to its kind, whose seed is in itself, on the earth: thus.</VERS>
<VERS vnumber="12 And the earth brought forth vegetation, plants yielding seed according to its kind, and the tree producing fruit, whose seed is in itself according to its kind. And God saw that it was good.</VERS>
[/code]
<br/>
View the full article
<div style="color:black; background-color:white
<pre><span style="color:blue private <span style="color:blue void Book_SelectedIndexChanged(<span style="color:blue object sender, EventArgs e)
{
<span style="color:blue string selectedBook = Book.SelectedItem.ToString();
<span style="color:blue string query = <span style="color:blue string.Format(<span style="color:#a31515 "//BIBLEBOOK[@bname=" + selectedBook + <span style="color:#a31515 "]/CHAPTER/@cnumber");
XmlNodeList Chapters = doc.SelectNodes(query);
<span style="color:blue string[] result = <span style="color:blue new <span style="color:blue string[Chapters.Count];
<span style="color:blue for (<span style="color:blue int i = 0; i < Chapters.Count; i++)
{
result = <span style="color:blue string.Concat(Chapters.InnerText);
}
Chapter.Items.AddRange(result);
<span style="color:green //textBox1.Text=
}
<span style="color:blue private <span style="color:blue void Chapter_SelectedIndexChanged(<span style="color:blue object sender, EventArgs e)
{
<span style="color:blue string selectedBook = Book.SelectedItem.ToString();
<span style="color:blue string selectedChapter = Chapter.SelectedItem.ToString();
<span style="color:blue string query = <span style="color:blue string.Format(<span style="color:#a31515 "//BIBLEBOOK[@bname=" + selectedBook + <span style="color:#a31515 "/CHAPTER/@cnumber="+selectedChapter+<span style="color:#a31515 "]");
<span style="color:green //wrong query here
[/code]
<div style="color:black; background-color:white
<pre> XmlNodeList verses = doc.SelectNodes(query);
}
[/code]
The xml file format:
<pre lang="x-xml <?xml version="1.0" encoding="ISO-8859-1" ?>
- <XMLBIBLE biblename="VW-Edition 2010
- <BIBLEBOOK bnumber="1" bname="Genesis
- <CHAPTER cnumber="1
<VERS vnumber="1 In the beginning God created the heavens and the earth.</VERS>
<VERS vnumber="2 And the earth was without form, and void, with darkness on the face of the deep; and the Spirit of God was hovering over the face of the waters.</VERS>
<VERS vnumber="3 Then God said, Let there be light! And there was light.</VERS>
<VERS vnumber="4 And God saw the light, that it was good; and God divided between the light and darkness.</VERS>
<VERS vnumber="5 God called the light, Day; and the darkness He called, Night. Thus, the evening and the morning: Day One.</VERS>
<VERS vnumber="6 Then God said, Let there be a firmament in the midst of the waters, separating the waters from the waters.</VERS>
<VERS vnumber="7 And God made the firmament, and separated the waters which were under the firmament from the waters which were above the firmament: thus.</VERS>
<VERS vnumber="8 And God called the firmament, Heavens. Thus, the evening and the morning: Day Two.</VERS>
<VERS vnumber="9 Then God said, Let the waters under the heavens be gathered together into one place, and let the dry land appear: thus.</VERS>
<VERS vnumber="10 And God called the dry land, Earth; and the gathering together of the waters He called, Seas. And God saw that it was good.</VERS>
<VERS vnumber="11 And God said, Let the earth sprout vegetation, plants yielding seed, and the fruit tree producing fruit according to its kind, whose seed is in itself, on the earth: thus.</VERS>
<VERS vnumber="12 And the earth brought forth vegetation, plants yielding seed according to its kind, and the tree producing fruit, whose seed is in itself according to its kind. And God saw that it was good.</VERS>
[/code]
<br/>
View the full article