LISTING 1: JavaScript to Retrieve Values from the Processing Instruction // parse_pi_data returns a 2-dim array of // pseudo attribute names and values vals = parse_pi_data(piNode); // assumes piNode is the PI // the href attribute value is the second element in the array alert("the href pseudo-attribute value is: " + vals[1][1]); function parse_pi_data(data) { pattrs = new Array(); // array to return pidata = data.split(" "); //parse the string - assume space separated for (i = 0 ; i < pidata.length ; i++) { pattrs[i] = parse_pseudo_attr(pidata[i]); } return(pattrs); } function parse_pseudo_attr(attr) { // use substring around '=' to parse name and value attrname = attr.substring(0,attr.indexOf("=")); value = attr.substring(attr.indexOf("=") + 2,attr.length - 1); return(new Array(attrname,value)); }