Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parsing XML with DOM
Message
 
À
17/11/2004 20:57:14
Information générale
Forum:
Visual FoxPro
Catégorie:
XML, XSD
Versions des environnements
Visual FoxPro:
VFP 7
Divers
Thread ID:
00962465
Message ID:
00962670
Vues:
7
In addition to Martins excellent suggestion-i can add some anecdotal observations:
I did some research on the "DOMDocument". The sources I looked at seemed to imply that the "cleanest version of DOM is 3.0:
oXML=CREATEOBJECT("MSXML2.DOMDocument.3.0")

In addition Martin's offer, there is another way. The nodes could be looped through (I prefer MArtins but have had issues with "getAttributenode". The nodes you provided do not seem to be documentelement "ROOT" nodes. Let's assume that the root node name is "schedules". We could set up the pointing scheme this way:
oSchedules=oXML.documentElement.childNodes(n) && A loop would have
                                              && to find the index
                                              && this would be the DOM root              
                                              && node "schedules:
* Now you could roll through the <schedule> child nodes by index:
for i= 0 to oSchedules.childNodes.length-1
?oSchedules.childNodes(i).attributes(0).text && for i=0, returns 
                                             &&'EP1877110087'
endfor
* When referencing from a childnode index, the "getAttributes" method
* is not available. getAttribute returns a node value based on the
* attribute name rather than the attribute index (number). In my situattion,
* I was face with attributes not being in a prescribed order and did not want
* to evaluate based on the nodename:
*(oSchedules.childNodes(i).attributes(0).nodename) - I need to pull by label
* but "attributes(n)" will not let me. So I played arround and found that:
for i= 0 to oSchedules.childNodes.length-1
oScheduleX=oSchedules.childNodes(i)
?oScheduleX.getAttributes("program") && Returns the value!!!
endfor
*As you see, assigning a reference to childnodes() tree allows use of 
*"getAttributes", where as applying "literal" heritage *"oSchedules.childNodes(i)" only allows index attribute retrieval!
None the less, I will study Martins method and try to figure it out!

>I followed the thread 904549 and found it very helpful but I was wondering if the DOM object (ox = createobject("MSXml.DOMDocument")) can extract the data when it is formatted as attributes of the element as in:
>
><schedule program='EP1877110087' station='19211' time='2004-11-19T23:00:00Z' duration='PT00H30M' stereo='true' closeCaptioned='true'/>
><schedule program='EP1877110088' station='19211' time='2004-11-19T23:30:00Z' duration='PT00H30M' stereo='true' closeCaptioned='true'/>
><schedule program='EP0174130101' station='19211' time='2004-11-20T00:00:00Z' duration='PT00H30M' stereo='true' closeCaptioned='true'/>
><schedule program='EP0174130102' station='19211' time='2004-11-20T00:30:00Z' duration='PT00H30M' stereo='true' closeCaptioned='true'/>
><schedule program='MV0782170000' station='19211' time='2004-11-20T01:00:00Z' duration='PT02H00M'/>
>
>Can anyone help me out here?
>
>Thanks
>- Don
Imagination is more important than knowledge
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform