- Searching and browsing XML documents
- XML functions and threads
- Deletion during a search
XMLFind (Function) In french: XMLRecherche
// Search from current position XMLFind("XMLDoc", "pri", XMLTag + XMLChildItem, XMLStartWith) WHILE XMLFound("XMLDoc") = True Info("Tag found " + XMLElementName("DocXML")) // Next element in the search XMLNext("XMLDoc") END XMLCancelSearch("XMLDoc") // Positions at the root of document XMLRoot("XMLDoc") // Exact-match search from the beginning of document XMLFind("XMLDoc", "price", XMLTag + XMLContinue, XMLExact) WHILE XMLFound("XMLDoc") = True Info("Tag found " + XMLElementName("DocXML")) // Next element in the search XMLNext("XMLDoc") END XMLCancelSearch("XMLDoc")
Syntax
<Result> = XMLFind(<XML document> , <Sought value> [, <Type of browse> [, <Search options>]])
<Result>: Boolean - True if the sought element is found,
- False otherwise.
<XML document>: Character string (with quotes) Name of XML document used. This document contains the XML code to study and it was created by XMLDocument. <Sought value>: Character string (with quotes) or NULL keyword Value sought in the XML document.If this parameter is set to NULL, all the tags and attributes of the XML document will be read from the current element, according to the search criteria. <Type of browse>: Optional constant (or combination of constants) Type of browse to perform: | | XMLAttribute | Search performed on the names of attributes. | XMLTag | Search performed on the names of tags. | XMLContinue | - Combined with XMLTag, XMLAttribute or XMLValue, continues the search in the rest of document while moving up in the levels of the tree structure (if necessary).
- Combined with XMLChildItem, continues the search in the rest of the document while moving up and down in the levels of the tree structure.
| XMLElement (Default value) | Search performed on the names of tags and attributes (equivalent to XMLTag + XMLAttribute). | XMLCurrentLevel | Search performed in the current level of tree structure. | XMLChildItem | Search performed in all the child tags. Must be combined with XMLTag, XMLAttribute or XMLValue. | XMLValue | Search performed on the values of tags and attributes. |
<Search options>: Optional constant (or combination of constants) Search options that will be taken into account: | | XMLWithNamespace | Search performed on the elements containing a namespace.
| XMLStartWith | Search performed on the elements starting with the sought value. | XMLContains | Search performed on the elements containing the sought value. | XMLExact (default value) | Exact-match and case-sensitive search. | XMLIgnoreCase | Search while ignoring the case of the tag. Can be combined with XMLContains, XMLStartWith or XMLExact. |
Remarks Searching and browsing XML documents XMLFind starts the search from the current position in the XML document. To perform a search in the entire document, we recommend that you use XMLRoot before the call to XMLFind. XMLFind affects the current browse. XMLNext and XMLPrevious will be positioned on the next and previous elements corresponding to the search. If the search fails (no element found), the current position before the beginning of the search is kept. XML functions and threads If your application uses threads, the XML document is shared between all these threads. See Managing threads for more details. If the current position in an XML document is modified in a thread, the current position in this XML document is modified for all the threads.
This page is also available for…
|
|
|
| |
| | https://youtu.be/v3TCiIa6ZbU
https://windevdesenvolvimento.blogspot.com/2019/04/dicas-2079-windevxml22lerduplicatasnotas.html
// EDT_XML=fLoadText(EDT_procura_xml)// estou lendo o conteudo do xml, que encontramos XMLDocument("xml_notas",EDT_XML) XMLFind("xml_notas",Null,XMLContinue+XMLChildItem) TableDeleteAll(TABLE_DUPLICATA) nome_tag is string="" sNumero_duplicata is string="" WHILE XMLFound("xml_notas") SWITCH XMLElementType("xml_notas") CASE XMLTag : nome_tag = XMLElementName("xml_notas") SWITCH nome_tag CASE "nDup" sNumero_duplicata=(XMLData("xml_notas")) OTHER CASE END IF sValor_duplicata<>"" THEN TableAddLine(TABLE_DUPLICATA,sNumero_duplicata,sData_vencimento,sValor_duplicata) sNumero_duplicata="" END END XMLNext("xml_notas") END
|
|
|
|
| |
| |
| |
|
| | TableDeleteAll(TABLE_NSU) sNome_tag is string="" sNome_Atributo is string="" s_meu_xml is string=EDT_xml //s_meu_xml is string=fLoadText(s_xml_documento) XMLDocument("XML",s_meu_xml) EDT_tpAmb=XMLRead("XML","/retDistDFeInt/tpAmb") XMLFind("XML",Null,XMLContinue+XMLChildItem) WHILE XMLFound("XML") SWITCH XMLElementType("XML") CASE XMLTag : sNome_tag = XMLElementName("XML") CASE XMLAttribute IF sNome_tag="docZip" THEN sNome_Atributo = XMLData("XML") IF IsNumeric(sNome_Atributo) THEN TableAddLine(TABLE_NSU,sNome_Atributo) END END END XMLNext("XML") END XMLClose("XML")
// BLOG COM VIDEO E EXEMPLO
http://windevdesenvolvimento.blogspot.com.br/2017/06/aula-1187-windev-010-xml-leritensxml.html
https://www.youtube.com/watch?v=8PcM8hBEM0w
|
|
|
|
| |
| |
| |
| |
| |
| |
| | |
|