Árvore de páginas

O método remove um atributo do nó elemento da expressão XPath.

Sintaxe

XPathDelAtt( < cXPathExpr >, < cAttName > )

Parâmetros

Nome

Tipo

Descrição

Obrigatório

Referência

cXPathExpr

caractere

Expressão XPath.

X


cAttName

caractere

nome do atributo desejado.

X


Retorno

Nome

Tipo

Descrição

lRet

lógico

Verdadeiro (.T.) caso tenha sido possivel remover. Falso (.F.) caso contrário.

Observações

  • O valor contido em <cXPathExpr> deve ser informado de acordo com o case no XML. Esta implementação é case sensitive.

Exemplos

Exemplo 1
user function XPDelAtt()
  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

  oXML:XPathRegisterNs( "ns", "http://myurl.com" )

  // Vai exibir
  // aAtt -> ARRAY (    1) [...]
  //      aAtt[1] -> ARRAY (    2) [...]
  //           aAtt[1][1] -> C (    5) [isNew]
  //           aAtt[1][2] -> C (    4) [true]
  aAtt := oXML:XPathGetAttArray( "/ns:book" )
  varinfo( "aAtt", aAtt )

  // Vai exibir ".F."
  conout( oXML:XPathDelAtt( "/ns:book", "xmlns" ) )

  // Vai exibir ".F."
  conout( oXML:XPathDelAtt( "/ns:book", "hardcover" ) )

  // Vai exibir
  // aAtt -> ARRAY (    1) [...]
  //      aAtt[1] -> ARRAY (    2) [...]
  //           aAtt[1][1] -> C (    5) [isNew]
  //           aAtt[1][2] -> C (    4) [true]
  aAtt := oXML:XPathGetAttArray( "/ns:book" )
  varinfo( "aAtt", aAtt )

  // Vai exibir ".T."
  conout( oXML:XPathDelAtt( "/ns:book", "isNew" ) )

  // Vai exibir
  // aAtt -> ARRAY (    0) [...]
  aAtt := oXML:XPathGetAttArray( "/ns:book" )
  varinfo( "aAtt", aAtt )
return
  • Sem rótulos