O método remove um atributo do nó atual do XML.
DOMDelAtt( < cAttName > ) |
Nome | Tipo | Descrição | Obrigatório | Referência |
|---|---|---|---|---|
cAttName | caractere | nome do atributo desejado. | X |
Nome | Tipo | Descrição |
|---|---|---|
lRet | lógico | Verdadeiro (.T.) caso tenha sido possivel remover. Falso (.F.) caso contrário. |
user function TXDelAtt()
Local cXML := ""
Local oXML
Local aAtt := {}
oXML := TXMLManager():New()
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
// 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 )
//Vai exibir "Could not delete attribute!"
if !oXML:DOMDelAtt( "xmlns" )
conout( "Could not delete attribute!" )
else
conout( "Attribute deleted!" )
endif
//Vai exibir "Could not delete attribute!"
if !oXML:DOMDelAtt( "hardcover" )
conout( "Could not delete attribute!" )
else
conout( "Attribute deleted!" )
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 )
//Vai exibir "Attribute deleted!"
if !oXML:DOMDelAtt( "isNew" )
conout( "Could not delete attribute!" )
else
conout( "Attribute deleted!" )
endif
// Vai exibir
// aAtt -> ARRAY ( 0) [...]
aAtt := oXML:DOMGetAttArray()
varinfo( "aAtt", aAtt )
return |