> No, what's xpath?  ...  Hmm, Parnassus lists three xpath packages
> (xml_indexer,
> a 4Suite tool, and PyXPath).  Which do you recommend?
> http://www.vex.net/parnassus/apyllo.py?so=d&find=xpath

XPath defines a W3C standard syntax for pulling information out of an
XML document.  We use 4Suite, they've been around a long time and have
some really nice stuff.  I don't know about the others, they may be just
as good.  

Spend 2 minutes here and you'll know the XPath syntax.
http://www.zvon.org/xxl/XPathTutorial/Output/example1.html

Or read the boring parts here :)
http://www.w3.org/TR/xpath


## Some random code from my library that may give you a little head
start.

v = self.value
LoanAmount = v('/report/subject/transaction/sale[1]/trust_deed_amount')


from Ft.Lib.pDomlette import PyExpatReader, Node
from xml import xpath
from xml.dom import ext
class XPathUtil:
        def node(self,path,contextNode=None):
                if contextNode == None:
                        contextNode = self._dom
                nodes = xpath.Evaluate(path, contextNode=contextNode)
                return nodes[0]

        def value(self,path):
                """ Return the text inside the element specified by the
xpath.  For now assume the xpath returns a single node. """
                nodes = xpath.Evaluate(path, contextNode=self._dom)
                text = ""
                node = nodes[0]
                if len(node.childNodes):
                        for child in node.childNodes:
                                if child.nodeType == Node.TEXT_NODE:
                                        text = text + child.data.strip()
                # we have to convert Unicode to text..
                return str(text)





_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to