代码示例:(标识:xdom_previoussibling)
<html>
<head>
<script type="text/javascript" src="/static/demo/html/js/loadxmldoc.js"> 
</script>
</head>
<body>
<script type="text/javascript">
//check if the previous sibling node is an element node
function get_previoussibling(n)
{
var x=n.previousSibling;
while (x.nodeType!=1)
  {
  x=x.previousSibling;
  }
return x;
}

xmlDoc=loadXMLDoc("/static/demo/xdom/books.xml");

var x=xmlDoc.getElementsByTagName("author")[0];
document.write(x.nodeName);
document.write(" = ");
document.write(x.childNodes[0].nodeValue);

var y=get_previoussibling(x);

document.write("<br />Previous sibling: ");
document.write(y.nodeName);
document.write(" = ");
document.write(y.childNodes[0].nodeValue);
</script>
</body>
</html>
运行结果: