user function XPGetN()
Local cXML := ""
Local oXML
oXML := TXMLManager():New()
cXML := '<book isNew="true">' + CRLF
cXML += ' <title>A Clash of Kings</title>' + CRLF
cXML += ' <author>George R. R. Martin</author>' + CRLF
cXML += ' <price>9.99</price>' + CRLF
cXML += ' <origin>US</origin>' + CRLF
cXML += '</book>' + CRLF
if !oXML:Parse( cXML )
conout( "Errors on Parse!" )
return
endif
// Vai exibir "A Clash of Kings"
conout( oXML:XPathGetNodeValue( "/book/title" ) )
// Vai exibir ""
conout( oXML:XPathGetNodeValue( "/song" ) )
// Vai exibir ""
conout( oXML:XPathGetNodeValue( "/song/composer" ) )
cXML := '<book xmlns="http://myurl.com" isNew="true">' + CRLF
cXML += ' <title>A Clash of Kings</title>' + CRLF
cXML += ' <author>George R. R. Martin</author>' + CRLF
cXML += ' <price>9.99</price>' + CRLF
cXML += ' <origin>US</origin>' + CRLF
cXML += '</book>' + CRLF
if !oXML:Parse( cXML )
conout( "Errors on Parse!" )
return
endif
// Vai exibir ""
conout( oXML:XPathGetNodeValue( "/book/title" ) )
oXML:XPathRegisterNs( "ns", "http://myurl.com" )
// Vai exibir ""
conout( oXML:XPathGetNodeValue( "/ns:book/title" ) )
// Vai exibir "A Clash of Kings"
conout( oXML:XPathGetNodeValue( "/ns:book/ns:title" ) )
return
|