Retorna um array com os namespaces do nó raiz do XML.
Sintaxe
XPathGetRootNsList()
Retorno
Nome | Tipo | Descrição |
---|---|---|
aNSList | vetor | Retorna um array de subarray, contendo o nome e o endereço do namespace do nó raiz do XML. |
Exemplos
Exemplo 1
user function XPGRNsL() Local cXML := "" Local oXML Local aNS := {} oXML := TXMLManager():New() cXML += '<book xmlns="http://myurl.com" xmlns:ns1="http://otherurl.com" isNew="true">' + CRLF cXML += ' <ns2:title xmlns:ns2="http://anotherurl.com">A Clash of Kings</ns2: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 // aNS -> ARRAY ( 2) [...] // aNS[1] -> ARRAY ( 2) [...] // aNS[1][1] -> C ( 5) [xmlns] // aNS[1][2] -> C ( 16) [http://myurl.com] // aNS[2] -> ARRAY ( 2) [...] // aNS[2][1] -> C ( 3) [ns1] // aNS[2][2] -> C ( 19) [http://otherurl.com] aNS := oXML:XPathGetRootNsList() varinfo( "aNS", aNS ) oXML:XPathRegisterNs( "ns", "http://myurl.com" ) oXML:XPathRegisterNs( "ns2", "http://anotherurl.com" ) // Vai exibir // aNS -> ARRAY ( 3) [...] // aNS[1] -> ARRAY ( 2) [...] // aNS[1][1] -> C ( 3) [ns2] // aNS[1][2] -> C ( 21) [http://anotherurl.com] // aNS[2] -> ARRAY ( 2) [...] // aNS[2][1] -> C ( 5) [xmlns] // aNS[2][2] -> C ( 16) [http://myurl.com] // aNS[3] -> ARRAY ( 2) [...] // aNS[3][1] -> C ( 3) [ns1] // aNS[3][2] -> C ( 19) [http://otherurl.com] aNS := oXML:XPathGetNsList( "/ns:book/ns2:title" ) varinfo( "aNS", aNS ) oXML:XPathAddNs( "/ns:book", "ns3", "http://myotherurl.com" ) // Vai exibir // aNS -> ARRAY ( 3) [...] // aNS[1] -> ARRAY ( 2) [...] // aNS[1][1] -> C ( 5) [xmlns] // aNS[1][2] -> C ( 16) [http://myurl.com] // aNS[2] -> ARRAY ( 2) [...] // aNS[2][1] -> C ( 3) [ns1] // aNS[2][2] -> C ( 19) [http://otherurl.com] // aNS[3] -> ARRAY ( 2) [...] // aNS[3][1] -> C ( 3) [ns3] // aNS[3][2] -> C ( 21) [http://myotherurl.com] aNS := oXML:XPathGetRootNsList() varinfo( "aNS", aNS ) return
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas