sklett wrote:
Quote:
<MedicalProfessional>
<FirstName>David</FirstName>
Quote:
medicalProfessionals =
medProdXMLDoc.getElementsByTagName("MedicalProfess ional");
alert('number of medical professionals returned: ' +
medicalProfessionals.length);
alert(medicalProfessionals[0].childNodes.length);
for(i = 0; i < medicalProfessionals[0].childNodes.length; i++)
{
alert(medicalProfessionals[0].childNodes[i].nodeName);
alert(medicalProfessionals[0].childNodes[i].nodeValue);
}
[/client script parsing code]
>
When the above codes runs, it correctly reports the length of
medicalProfessionals
It correctly reports the number of childNodes
It correctly reports the NAME of the child nodes in the loop
It reports null for all the child node values -
Well in the DOM if you have an element node then nodeValue is defined as
null. It is _not_ the text content of the element. If you want that then
you need the text property for MSXML or textContent for Firefox/Mozilla
or Opera 9.
And if you script XML on the web then be aware that the different
parsers your script will encounter might treat white space different,
for instance Mozilla will have text nodes with white space between
element nodes. So a script looking for an element node with e.g.
childNodes[certainIndex] might find an element node with one parser
(e.g. MSXML) but a text node with another parser (e.g. Mozilla). Thus if
you are looking for element child nodes then if you loop through
childNodes or index it check the nodeType, or better yet don't use
childNodes but rather XPath (e.g. selectSingleNode/selectNodes with
MSXML, DOM Level 3 XPath API with Mozilla and with Opera 9) to look for
the child elements.
Client-side scripting questions are better asked in comp.lang.javascript
or if they relate to XML in comp.text.xml. The Microsoft server has
microsoft.public.xml for instance and various JScript scripting groups.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/