user function TXAAttA()
Local cXML := ""
Local oXML
Local aAtt := {}
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
// aAtt -> ARRAY ( 1) [...]
// aAtt[1] -> ARRAY ( 2) [...]
// aAtt[1][1] -> C ( 5) [isNew]
// aAtt[1][2] -> C ( 4) [true]
aAtt := oXML:DOMGetAttArray()
varinfo( "aAtt", aAtt )
aAtt := { { "hardcover", "no" } }
//Vai exibir "Attribute added!"
if !oXML:DOMAddAttArray( aAtt )
conout( "Could not add attribute!" )
else
conout( "Attribute added!" )
endif
// Vai exibir
// aAtt -> ARRAY ( 2) [...]
// aAtt[1] -> ARRAY ( 2) [...]
// aAtt[1][1] -> C ( 5) [isNew]
// aAtt[1][2] -> C ( 4) [true]
// aAtt[2] -> ARRAY ( 2) [...]
// aAtt[2][1] -> C ( 9) [hardcover]
// aAtt[2][2] -> C ( 2) [no]
aAtt := oXML:DOMGetAttArray()
varinfo( "aAtt", aAtt )
return
|