I am developing my knowledge base files these days and also I am trying to make an interface to update the templates in the knowledge base.
Say I have the following AIML file.

<?xml version=“1.0” encoding=“ISO-8859-1”?>
<aiml version=“1.0”>
  <category>
   <pattern> WHERE</pattern>
  <template>Where the heart is.</template>
  </category>
  <category>


  <category>
    <pattern>Hi</pattern>
  <template>Hello there</template>
  </category>
  <category>
</aiml>

I want to access the first pattern template. I am using c# for the development and the following coded gives only the InnterText of the specified Tag.

XmlNodeList nodelist = aiml.GetElementsByTagName(“pattern”);
TextBox1.Text = nodelist[0].InnerText;
or 
TextBox1.Text = nodelist[0].FirstChild.ChildNodes[0].InnerText;

But what I want is; if I give the pattern node list no as 0 or 1 then I need to read the InnerText of the related template.
Is there a way that I can get the access like that??
Any suggestions????
Thank you.

Use System.Xml.SelectNodes( strXPath ) or System.Xml.SelectSingleNode( strXPath ). Construct the strXPath something like this "/aiml/category/pattern"
Good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.