Searching for a tag name in XML

Sarah Reichelt sarah.reichelt at gmail.com
Tue Apr 21 19:11:07 EDT 2009


On Wed, Apr 22, 2009 at 1:20 AM, David Bovill <david at vaudevillecourt.tv> wrote:
> Looks like there is no easy way to search for an XML node? I want to search
> for a "<table>" element in xHTML. I can pull it out by looking for a
> particular value for the param - say border:
>
> put revXMLMatchingNode (treeID, pStartNode, "table", "border", "2", -1) into
> foundNode
>
> but given that it may or may not have such parameters:
>
> put revXMLMatchingNode (treeID, pStartNode, "table", "", "", -1) into
> foundNode
>
> does not find anything.
>
> I can of course use built in rev commands to find the tag - but then it is
> not so easy to find the nodes path in the XML tree so I can pull out the
> entire table reliably from the xHTML.
>
> Is there any way to do this?


Untested but how about, using revXMLNodeContents and just trying to
find a table node e.g. "html[1]/body[1]/table[1]".
If there isn't one, you should get an xmlErr report.
If there is, you can loop on to looking for "html[1]/body[1]/table[2]"


HTH,
Sarah



More information about the use-livecode mailing list