htmlText, xHTML and revXML

David Bovill david at openpartnership.net
Sat Dec 23 01:17:53 EST 2006


I am using the script to parse the htmltext of Revs text fields - so it is a
nice fixed target. Here is the script I have at the moment modified slightly
from your suggestions to work with anchors:

function html_ExtractAnchors someHtml
    put someHtml into htmlPage
    replace CR with empty in htmlPage --text is now one line
    replace "name=" with "name=" & CR in htmlPage
    replace "</a" with "</a" & CR in htmlPage

    -- filter htmlPage with "*http://*"
    -- set the itemdel to ">"
    filter htmlPage with (quote & "*</a")
    set the itemdel to quote

    put empty into newLinkList
    repeat for each line LNN in htmlPage
        put item 2 of LNN & cr after newLinkList
        -- put item 1 of LNN & cr after newLinkList
    end repeat
    delete last char of newLinkList
    return newLinkList
end html_ExtractAnchors

NB - anyone managed to use  the XML libraries on htmltext - this is the sort
of thing I mean - which fais with html entities:

function html_AttributeValues someHtml, attributeName, childName, depth
    -- does not work with htmlEntities!

    put revCreateXMLTree(someHtml, true, true, false) into treeID
    if char 1 to 6 of treeID is "xmlerr" then
        put someHtml
        opn_Notify treeID, true
        exit to top
    end if

    if depth is empty then put -1 into depth
    put revXMLRootNode(treeID) into startNode
    put revXMLAttributeValues(treeID, startNode, childName, attributeName,
CR, depth) into attributeValues
    revDeleteXMLTree treeID
    return word 1 to -1 of attributeValues
end html_AttributeValues

Would be nice...



More information about the use-livecode mailing list