Retorna o conteúdo de um namespace do nó atual do XML.
DOMGetNs( < cAttName > ) |
Nome | Tipo | Descrição | Obrigatório | Referência |
|---|---|---|---|---|
cAttName | caractere | Indica o nome do namespace desejado. | X |
Nome | Tipo | Descrição |
|---|---|---|
cAttValue | caractere | Retorna uma string vazia, se obteve erro. Caso contrário, o conteúdo do namespace informado. |
user function TXGetNs()
Local cXML := ""
Local oXML
Local aNS := {}
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) [xmlns]
// aAtt[1][2] -> C ( 16) [http://myurl.com]
aNS := oXML:DOMGetNsList()
varinfo( "aNS", aNS )
// Vai exibir ""
conout( oXML:DOMGetNS( "xmlns" ) )
// Vai exibir ""
conout( oXML:DOMGetNS( "ns1" ) )
// Vai exibir "Namespace added!"
if !oXML:DOMAddNs( "ns1", "http://myotherurl.com" )
conout( "Could not add namespace!" )
else
conout( "Namespace added!" )
endif
// Vai exibir
// aAtt -> ARRAY ( 2) [...]
// aAtt[1] -> ARRAY ( 2) [...]
// aAtt[1][1] -> C ( 5) [xmlns]
// aAtt[1][2] -> C ( 16) [http://myurl.com]
// aAtt[2] -> ARRAY ( 2) [...]
// aAtt[2][1] -> C ( 3) [ns1]
// aAtt[2][2] -> C ( 21) [http://myotherurl.com]
aNS := oXML:DOMGetNsList()
varinfo( "aNS", aNS )
// Vai exibir ""
conout( oXML:DOMGetNS( "xmlns" ) )
// Vai exibir "http://myotherurl.com"
conout( oXML:DOMGetNS( "ns1" ) )
return |