xmldom 以及javascript

nmg發表於2002-12-31
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 class="indent">

相關文章