user function TXNewChN()
Local cXML := ""
Local oXML
Local aChildren := {}
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 "book"
conout( oXML:CNAME )
// Vai exibir
// aChildren -> ARRAY ( 4) [...]
// aChildren[1] -> ARRAY ( 2) [...]
// aChildren[1][1] -> C ( 5) [title]
// aChildren[1][2] -> C ( 16) [A Clash of Kings]
// aChildren[2] -> ARRAY ( 2) [...]
// aChildren[2][1] -> C ( 6) [author]
// aChildren[2][2] -> C ( 19) [George R. R. Martin]
// aChildren[3] -> ARRAY ( 2) [...]
// aChildren[3][1] -> C ( 5) [price]
// aChildren[3][2] -> C ( 4) [9.99]
// aChildren[4] -> ARRAY ( 2) [...]
// aChildren[4][1] -> C ( 6) [origin]
// aChildren[4][2] -> C ( 2) [US]
aChildren := oXML:DOMGetChildArray()
varinfo( "aChildren", aChildren )
// Vai exibir ".F."
conout( oXML:DOMNewChildNode( "", "no" ) )
// Vai exibir ".T."
conout( oXML:DOMNewChildNode( "hardcover", "no" ) )
// Vai exibir
// aChildren -> ARRAY ( 5) [...]
// aChildren[1] -> ARRAY ( 2) [...]
// aChildren[1][1] -> C ( 5) [title]
// aChildren[1][2] -> C ( 16) [A Clash of Kings]
// aChildren[2] -> ARRAY ( 2) [...]
// aChildren[2][1] -> C ( 6) [author]
// aChildren[2][2] -> C ( 19) [George R. R. Martin]
// aChildren[3] -> ARRAY ( 2) [...]
// aChildren[3][1] -> C ( 5) [price]
// aChildren[3][2] -> C ( 4) [9.99]
// aChildren[4] -> ARRAY ( 2) [...]
// aChildren[4][1] -> C ( 6) [origin]
// aChildren[4][2] -> C ( 2) [US]
// aChildren[5] -> ARRAY ( 2) [...]
// aChildren[5][1] -> C ( 9) [hardcover]
// aChildren[5][2] -> C ( 2) [no]
aChildren := oXML:DOMGetChildArray()
varinfo( "aChildren", aChildren )
return
|