- for ( i = 0; i < recordNode.childNodes.length; i++) {
- if ( recordNode.childNodes[i].nodeType
- == Node.ELEMENT_NODE
- && recordNode.childNodes[i].nodeName
- != 'location' ) {
- var nodeName =
- recordNode.childNodes[i].nodeName;
- var nodeText = '';
- if (recordNode.childNodes[i].firstChild)
- nodeText = recordNode.childNodes[i]
- .firstChild.nodeValue;
- record[nodeName] = nodeText;
- }
- }
- // the location might be empty!!
- var locationNodes =
- recordNode.getElementsByTagName("location");
- record["location"] = new Array();
- for ( i = 0; i < locationNodes.length; i++ ) {
- record["location"][i] = {
- "id": locationNodes[i].getAttribute("id"),
- "name": locationNodes[i].getAttribute("name")
- };
-
- for (j = 0;
- j < locationNodes[i].childNodes.length;
- j++) {
- if ( locationNodes[i].childNodes[j].nodeType
- == Node.ELEMENT_NODE ) {
- var nodeName =
- locationNodes[i].childNodes[j].nodeName;
- var nodeText = '';
- if (locationNodes[i].childNodes[j]
- .firstChild)
- nodeText =
- locationNodes[i].childNodes[j]
- .firstChild.nodeValue;
- // this is stupid
- if (nodeName == 'md-subject') {
- if (record["location"][i]['nodeName']) {
- record["location"][i][nodeName]
- .push(nodeText)
- } else {
- record["location"][i][nodeName]
- = new Array();
- record["location"][i][nodeName]
- .push(nodeText)
- }
- } else {
- record["location"][i][nodeName]
- = nodeText;
- }
- }
- }
- }
- }
-
- callback(record, handle);