This is a little ECMAscript for XML demo. Click on the buttons please.

Here is the JS code for the above buttons:
function subgoals() {
      var subgoals = xml..subgoal;
      alert (subgoals);
      }

function attempt_action() {
      var action = xml..ATTEMPT[1].action;
      alert (action);
      }

function show_URL() {
      var NS = new Namespace("http://www.w3.org/1999/xlink");
      // this works
      var URL = xml..a;
      var link = URL.@NS::href;
      alert ("URL (content of the 'a' tag)=" + URL + "\n" + "NameSpace=" + NS + "\nxlink:href=" + link);
      }

Here is the XML (just copy/paste from the head, you really should look at the source of this page).


<STORY>
  <title>The little Flexer</title>
  <context>Once upon a time, in a dark small office.</context>
  <problem>Kaspar was trying to learn Flex but didn't have a real project. He then decided that it would be a good idea to look at Data-Driven Controls. These are most useful in combination with an external datasources in XML format.</problem>
  <goal>So he decided how to write a mx:Tree application that imports XML data.</goal>
  <THREADS>
    <EPISODE>
      <subgoal>He decided to play with a little example</subgoal>
      <ATTEMPT>
	<action>So he went to see the LiveDocs and copied an example</action>
      </ATTEMPT>
      <result>The example worked but he didn't understand why since he didn't know about E4X</result>
    </EPISODE>
    <EPISODE>
      <subgoal>He then decided to learn e4X firs
</subgoal>
      <ATTEMPT>
	<action>
	Reading 2-3 tutorials and creating a simple example only took 2-3 hours.
        </action>
      </ATTEMPT>
      <result>
      He now understood how to write e4X code in Flex
</result>
    </EPISODE>
  </THREADS>

  <moral>Divide a problem into subproblems and you will get there ...</moral>
  <INFOS>
    <a xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://edutechwiki.unige.ch/en/ECMAscript_for_XML">
          ECMAscript for XML</a>
  </INFOS>
</STORY>


DKS - nov 2008 - Freeware - BAD HTML 4.0 ;). ... I think I should put the JS code in a separate file.