How can I find specific parts of an XML and feed them into dialogue?

I've tried googling and searching Unity Answers/Forums, but all I come up with are things to load entire XML documents. What I would like to do is make a Javascript (preferably Java) that will allow me to read specific dialogue lines from an XML file.

I got this, which seems to be similar to what I need: http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=312&page=1 (also found an XML parser, but that loads entire XMLs as well[?]: http://forum.unity3d.com/viewtopic.php?t=40708&highlight=xml+parse)

But I have no idea how I would turn this into Javascript, I'm really a beginner.

So, in short, I want a script that can read, for instance, this XML:

<scenes>
  <scene1>
   <actor>Bob</actor>
   <line1>"Oh, hi thare!"</line1>
   <line2>"This is my second line."</line2>
  </scene1>
  <scene2>
   <actor>Bill</actor>
   <line1>"I'm another actor!"</line1>
  </scene2>
</scenes>

Naturally I would want to load that function from another script. I hope you can help me out! If there is more information needed, I'll be happy to supply it.

If you use the parser that you linked to you can do something like:

public var dialogueXMLFile:TextAsset;
public var dialogue:XMLNode;

function Start(){
   var parser=new XMLParser();
   dialogue=parser.Parse(dialogueXMLFile.text);
}

You can then access your dialogue as:

Debug.Log(dialogue.GetValue("scene>0>actor>0>line>0>_text"));
Debug.Log(dialogue.GetValue("scene>0>actor>0>line>1>_text"));

(though the arrays start from 0 rather than 1 unlike your ids in your XML document)

If you want to loop through the dialogue you can do:

for(var n:XMLNode in dialogue.GetNodeList("scene>0>actor>0>line")){
         Debug.Log(n.GetValue("_text"));
}

Complete script I'm testing with:

public var dialogueXMLFile:TextAsset;
public var dialogue:XMLNode;

function Start(){
   var parser=new XMLParser();
   dialogue=parser.Parse(dialogueXMLFile.text);
   Debug.Log(dialogue.GetValue("scene>0>actor>0>line>0>_text"));
   Debug.Log(dialogue.GetValue("scene>0>actor>0>line>1>_text"));

   for(var n:XMLNode in dialogue.GetNodeList("scene>0>actor>0>line")){
         Debug.Log(n.GetValue("_text"));
   }
}

Getting the dialogue lines from the XML file, every time you need them can be quiet slow. But you can parse the XML file at the beginning and store the dialogue lines in an array for example. I would also change the XML structure a little bit... but you structure will do it as well. :)

<scene nr="1">
  <actor name="Bob">
   <line id="1">"Oh, hi thare!"</line>
   <line id="2">"This is my second line."</line>
  </actor>
</scene>
<scene nr=2>
  <actor name="Bill">
   <line id="1">"I'm another actor!"</line>
  </actor>
</scene>

And here an idea for the script (sorry, it's in C#):

public TextAsset dialogueXMLFile;

private void parseXML()
{
   XmlDocument xmlDoc = new XmlDocument();
   xmlDoc.LoadXml(dialogueXMLFile.text);
   XmlNodeList NodeList = xmlDoc.GetElementsByTagName("scene");

   foreach (XmlNode sceneNode in NodeList)
   {
       //Get Scene Number
       int sceneNr = sceneNode.Attributes["nr"].Value;

       //get actors
       foreach (XmlNode actorNode in sceneNode.ChildNodes)
       {
           //Get Actor name
           string actorName = actorNode.Attributes["name"].Value;

           //get lines and store the data in an array or what ever...
       }
   }