S
sklett
** I tried to find a more suitable NG for this issue but didn't find much
(on the MS server) the ones I did find haven't had posts in a loooong time.
Sorry for the somewhat off topic post **
My Situation:
client side scripts make an ajax request for some data
aspx page processes request and writes back an XML (not perfectly formed)
file
client side script receives data and attempts to parse the XML (this is
where I'm having a hard time)
Here is a sample of what the XML looks like:
[xml sample]
<?xml version="1.0" encoding="utf-8" ?>
<MedicalProfessionals>
<count>3</count>
<MedicalProfessional>
<FirstName>David</FirstName>
<LastName>Jones</LastName>
<Address1>123 SomeStreet</Address1>
<Address2>Suite #4</Address2>
<City>Irvine</City>
<State>California</State>
<ZipCode>92614</ZipCode>
<Phone>949-333-2222</Phone>
<AltPhone>949-888-9874</AltPhone>
<Fax>949-111-2345</Fax>
<Notes>This is a good Dr.</Notes>
<UPIN>11223344</UPIN>
<NSInternalID>1</NSInternalID>
</MedicalProfessional>
</MedicalProfessionals>
[/xml sample]
Here is some of the client parsing script:
[client script parsing code]
medicalProfessionals =
medProdXMLDoc.getElementsByTagName("MedicalProfessional");
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.nodeName);
alert(medicalProfessionals[0].childNodes.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 - this is the part that is
kicking my butt.
I have checked that the XML being sent to the client is populated with data
for those nodes and it is. I really don't know why it would report them as
null.
Does anyone see a problem with this code? Any ideas? I'm about to revert
to a delimited string and parse the "old fashioned" way but I would much
rather use XML.
2 more questions:
1) Is there a way to load an XML STRING using firefox? I have been trying
to pass the string to the load() method of the firefox XML Dom Parser object
but it wants a file path. Any ideas?
2) Is there a way to access a childNode by nodeName instead of index? I
hate accessing things by index as it's so prone to bugs. I know I can
implement a search function to find them, but it sure seems like this is
something that should be available out of the box. maybe I'm missing it?
Thanks for reading and again, sorry for the off topic post, but you guys are
all very knowledgeable with web technologies and I didn't know where else to
turn. :0)
-Steve
(on the MS server) the ones I did find haven't had posts in a loooong time.
Sorry for the somewhat off topic post **
My Situation:
client side scripts make an ajax request for some data
aspx page processes request and writes back an XML (not perfectly formed)
file
client side script receives data and attempts to parse the XML (this is
where I'm having a hard time)
Here is a sample of what the XML looks like:
[xml sample]
<?xml version="1.0" encoding="utf-8" ?>
<MedicalProfessionals>
<count>3</count>
<MedicalProfessional>
<FirstName>David</FirstName>
<LastName>Jones</LastName>
<Address1>123 SomeStreet</Address1>
<Address2>Suite #4</Address2>
<City>Irvine</City>
<State>California</State>
<ZipCode>92614</ZipCode>
<Phone>949-333-2222</Phone>
<AltPhone>949-888-9874</AltPhone>
<Fax>949-111-2345</Fax>
<Notes>This is a good Dr.</Notes>
<UPIN>11223344</UPIN>
<NSInternalID>1</NSInternalID>
</MedicalProfessional>
</MedicalProfessionals>
[/xml sample]
Here is some of the client parsing script:
[client script parsing code]
medicalProfessionals =
medProdXMLDoc.getElementsByTagName("MedicalProfessional");
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.nodeName);
alert(medicalProfessionals[0].childNodes.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 - this is the part that is
kicking my butt.
I have checked that the XML being sent to the client is populated with data
for those nodes and it is. I really don't know why it would report them as
null.
Does anyone see a problem with this code? Any ideas? I'm about to revert
to a delimited string and parse the "old fashioned" way but I would much
rather use XML.
2 more questions:
1) Is there a way to load an XML STRING using firefox? I have been trying
to pass the string to the load() method of the firefox XML Dom Parser object
but it wants a file path. Any ideas?
2) Is there a way to access a childNode by nodeName instead of index? I
hate accessing things by index as it's so prone to bugs. I know I can
implement a search function to find them, but it sure seems like this is
something that should be available out of the box. maybe I'm missing it?
Thanks for reading and again, sorry for the off topic post, but you guys are
all very knowledgeable with web technologies and I didn't know where else to
turn. :0)
-Steve