comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » loop for XML
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: loop for XML [message #89825 is a reply to message #89824] Sat, 06 December 2014 10:57 Go to previous messageGo to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 12/6/14, 6:17 am, skymaxwell wrote:
> Hi
>
> I need read the XML file. Here is the fragment of file
>
> <root>
> <Key1>
> <p1>13</p1>
> <tb1>10</tb1>
> </Key1>
> <KeyMeta>
> <ax>21</ax>
> <ay>59</ay>
> <az>26.7</az>
> </KeyMeta>
> </root>
>
>
> I was looking here something about XML, I find simple example with single tag
> There used these functions (oValue->GetFirstChild())->GetNodeValue())
>
>
> How build construction for multiple tags as my case ?
> I didn't find any functions in IDL help, which i could use in my case.
> May be I don't understand function Item(i).
>
> Here part of code
> ==============
> p=OBJ_NEW('IDLffXMLDOMDocument')
> p->Load,FILENAME=filenameXML
> oTopLevel=p->GetDocumentElement() ;return root IDLffXMLDOMDocument
> ; tag with name
> mainTagsList=oTopLevel->GetElementsByTagName("KeyMeta")
> ; how many KeyMeta tags in documents
> PRINT,"Length=",mainTagsList->GetLength()
> ;loop
> FOR i=0,mainTagsList->GetLength()-1 DO BEGIN
> ;How to do correct loop ???
> ENDFOR
>
> ==============
>
>
> thanks
>

Try this:

p = obj_new('IDLffXMLDOMDocument')
p->load, filename=filenameXML

oTopLevel = p->getDocumentElement() ;return root IDLffXMLDOMDocument

; tag with name
metaList = oTopLevel->getElementsByTagName('KeyMeta')
; how many KeyMeta tags in documents
metaElement = metaList->item(0)
metaChildrenList = metaElement->getElementsByTagname('*')
for c = 0L, metaChildrenList->getLength() - 1L do begin
item = metaChildrenList->item(c)
name = item->getTagname()
dataList = item->getFirstChild()
value = dataList->getNodeValue()
print, name, value, format='(%"%s = %s")'
endfor

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Referencing structure inline
Next Topic: help regarding curvefit

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:38:03 PDT 2025

Total time taken to generate the page: 0.00354 seconds