revXML help

Jan Schenkel janschenkel at yahoo.com
Fri Jul 2 15:09:43 EDT 2010


--- On Fri, 7/2/10, Simon Lord <slord at karbonized.com> wrote:
> I'm tearing my hair out trying to
> read various values.  What should be
> trivial is continuously spitting errors in my face and I'm
> quite
> frustrated.  :P
> 
> Here is my XML—it is successfully loaded into my stack
> after reading
> it in.  I can also get the root node and ID.  But
> I can't get anything
> else to work for me.  Here is the code, my question(s)
> will follow
> after it:
> 
> <?xml version="1.0"?>
> <testXML>
> 
>   <project name="Stage 1" splash=""
> icon="/Users/slord/test/projects/DCP_0254.jpg">
>     <screen name="">
>       <image id="" zindex="" path=""
> height="" width="" top="" left=""
> start="" end="" url="">
>       </image>
>     </screen>
>    </project>
> 
>   <project name="Stage 2" splash=""
> icon="/Users/slord/test/projects/DCP_0254.jpg">
>     <screen name="">
>       <image id="" zindex="" path=""
> height="" width="" top="" left=""
> start="" end="" url="">
>       </image>
>     </screen>
>    </project>
> 
>   <project name="Stage 3" splash=""
> icon="/Users/slord/test/projects/DCP_0254.jpg">
>     <screen name="">
>       <image id="" zindex="" path=""
> height="" width="" top="" left=""
> start="" end="" url="">
>       </image>
>     </screen>
>    </project>
> 
> </testXML>
> 
> To start off, I need to get the attribute for "icon" in
> "project".
> 
> Here is my code to date:
> 
> repeat for
> revXMLNumberOfChildren(tDocID,"testXML","project",1) times
>     put revXMLRootNode(tDocID) into tParentNode
> // this works, thanks Sarah!
>     put revXMLAttribute(tDocID, tParentNode,
> "icon") into tChild //
> returns error
> end repeat
> 
> I also need to know how to loop through all 3
> <project> nodes getting
> the value for "icon". IE, tParentNode[x].
> 

To traverse the children of a node, you can use the following type of loop:
##
put revXmlFirstChild(tDocId, tParentNode) into tChildNode
repeat until tChildNode is empty
  -- do your thing with the child node
  put revXmlAttribute(tDocId, tChildNode, "icon") into tIconPath
  -- move on to the next child
  put revXmlNextSibling(tDocId, tChildNode) into tChildNode
end repeat
##

HTH,

Jan Schenkel.
=====
Quartam Reports & PDF Library for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


      




More information about the use-livecode mailing list