xmldom 以及javascript

02-12-31 nmg

a.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" ?>
<Data>
	<anRecord>
		<DEPARTMENTID>7</DEPARTMENTID>
		<DEPARTMENTNAME>总公司</DEPARTMENTNAME>
		<DEPARTMENTPHONE>departmentPhone7</DEPARTMENTPHONE>
		<LOGINUSERID>ssss</LOGINUSERID>
		<DEPARTMENTFAX>departmentFax7</DEPARTMENTFAX>
		<DEPARTMENTADDRESS>7</DEPARTMENTADDRESS>
		<PARENTID>0</PARENTID>
		<DESCRIPTION>是一家
大企业</DESCRIPTION>
	</anRecord>
	<anRecord>
		<DEPARTMENTID>491</DEPARTMENTID>
		<DEPARTMENTNAME>行政部</DEPARTMENTNAME>
		<DEPARTMENTPHONE>null</DEPARTMENTPHONE>
		<LOGINUSERID>test</LOGINUSERID>
		<DEPARTMENTFAX>null</DEPARTMENTFAX>
		<DEPARTMENTADDRESS>null</DEPARTMENTADDRESS>
		<PARENTID>7</PARENTID>
		<DESCRIPTION>行政部负责日常事务处理
</DESCRIPTION>
	</anRecord>
	</Data>

test.html:

script type="text/javascript">
function search()
{
var parser=new ActiveXObject("microsoft.xmldom")
parser.async="false"
parser.load("a.xml)
nodes = parser.documentElement.childNodes
answer_text.innerHTML=nodes.item(0).text
answer_xml.value=parser.xml
}
</script>

1.请问如何得到Element 的个数,
以及 data/anRecord/DEPARTMENTNAME
该节点的值?
2.请问那有xmldom控件的用法,关于xmldom的属性和方法?
多谢各位!

<p>

banq
2003-01-02 10:48

微软的东西我不懂。

hanker
2003-01-03 09:55

IE5.5以上能自动解析.用不着那么麻烦.

查查xml-dso.