PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Searching and browsing XML documents
  • XML functions and threads
  • Deletion during a search
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Performs a search in an XML document. This search can be canceled by XMLCancelSearch.
Versions 15 and later
Android This function is now available for the Android applications.
New in version 15
Android This function is now available for the Android applications.
Android This function is now available for the Android applications.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
// 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(<Name of XML Document> , <Sought Value> [, <Type of Browse> [, <Search Options>]])
<Result>: Boolean
  • True if the sought element is found,
  • False otherwise.
<Name of 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:
XMLAttributeSearch performed on the names of attributes.
XMLTagSearch 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).
XMLCurrentLevelSearch performed in the current level of tree structure.
XMLChildItemSearch performed in all the child tags. Must be combined with XMLTag, XMLAttribute or XMLValue.
XMLValueSearch performed on the values of tags and attributes.
<Search Options>: Optional constant (or combination of constants)
Search options that will be taken into account:
XMLWithNamespaceSearch performed on the elements containing a namespace.
WEBDEV - Browser code This constant is not available.
XMLStartWithSearch performed on the elements starting with the sought value.
XMLContainsSearch performed on the elements containing the sought value.
XMLExact
(default value)
Exact-match and case-sensitive search.
XMLIgnoreCaseSearch 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.
To cancel the search, use XMLCancelSearch. Furthermore, XMLFirst, XMLLast, XMLRoot, XMLParent and XMLChild cancel the current search.

XML functions and threads

If your application is using threads, the XML document is shared among all these threads. See Managing the 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.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadWindows MobileUniversal Windows 10 AppJavaPHPAjaxUser code (UMC)

Deletion during a search

XMLDelete used during a search cancels the search.
Example to avoid (this code does not operate):
// Positions at the root of document
XMLRoot(:m_sDocName)
// Finds all the "txsr" from the root in order to delete them
XMLFind(:m_sDocName, CParagraph::CST_TAG, XMLTag + XMLChildItem + XMLContinue, XMLExact)
WHILE XMLFound(:m_sDocName) = True
XMLDelete(:m_sDocName)
// Next element in the search
XMLNext(:m_sDocName)
END
XMLCancelSearch(:m_sDocName)
The following code must be used:
// Deletion during a search
// Positions at the root of document
XMLRoot(:m_sDocName)
LOOP
// Finds all the "txsr" from the root in order to delete them
XMLFind(:m_sDocName, CParagraph::CST_TAG , ...
  XMLTag + XMLChildItem + XMLContinue, XMLExact)
IF XMLFound(:m_sDocName) = True THEN
XMLDelete (:m_sDocName)
ELSE
BREAK
END
END
Components
WINDEVWEBDEV - Server codeReports and Queries wd230xml.dll
Windows Mobile wp230xml.dll
WEBDEV - Browser code WDJS.DLL
Java wd230java.jar
Linux wd230xml.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
LER ITEM XML
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



De matos
Jun. 24 2017