|
|
|
|
|
- Searching and browsing XML documents
- XML functions and threads
- Deleting an element during a search
XMLFind (Function) In french: XMLRecherche Performs a search in an XML document. This search can be canceled by XMLCancelSearch.
XMLFind("XMLDoc", "pri", XMLTag + XMLChildItem, XMLStartWith)
WHILE XMLFound("XMLDoc") = True
Info("Tag found " + XMLElementName("DocXML"))
XMLNext("XMLDoc")
END
XMLCancelSearch("XMLDoc")
XMLRoot("XMLDoc")
XMLFind("XMLDoc", "price", XMLTag + XMLContinue, XMLExact)
WHILE XMLFound("XMLDoc") = True
Info("Tag found " + XMLElementName("DocXML"))
XMLNext("XMLDoc")
END
XMLCancelSearch("XMLDoc")
Syntax
<Result> = XMLFind(<XML document> , <Search value> [, <Type of iteration> [, <Search options>]])
<Result>: Boolean - True if the sought element is found,
- False otherwise.
<XML document>: Character string Name of the XML document used. This document contains the XML code to study and it was created by XMLDocument. <Search value>: Character string (with quotation mark) 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 iteration>: Optional constant (or combination of constants) Type of iteration to perform: | | XMLAttribute | Search performed on the names of attributes. | XMLChildItem | Search performed in all the child tags. Must be combined with XMLTag, XMLAttribute or XMLValue. | 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.
| XMLCurrentLevel | Search performed in the current level of tree structure. | XMLElement (Default value) | Search performed on the names of tags and attributes (equivalent to XMLTag + XMLAttribute). | XMLTag | Search performed on the names of tags. | 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: | | XMLContains | Search performed on the elements containing the sought value. | XMLExact (default value) | Exact-match and case-sensitive search. | XMLIgnoreCase | Search ignoring the case of the tag. Can be combined with XMLContains, XMLStartWith or XMLExact. | XMLStartWith | Search performed on the elements starting with the sought value. | XMLWithNamespace | Search performed on the elements containing a namespace.
|
Remarks Searching and browsing XML documents XMLFind starts the search from the current position in the XML document. To search in the entire document, it is recommended to use XMLRoot before using XMLFind. XMLFind affects the current search. 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. For more details on threads, see Managing threads. 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. Deleting an element during a search XMLDelete used during a search cancels the search. Example to avoid (this code does not operate):
XMLRoot(:m_sDocName)
XMLFind(:m_sDocName, CParagraph::CST_TAG, XMLTag + XMLChildItem + XMLContinue, XMLExact)
WHILE XMLFound(:m_sDocName) = True
XMLDelete(:m_sDocName)
XMLNext(:m_sDocName)
END
XMLCancelSearch(:m_sDocName)
The following code must be used:
XMLRoot(:m_sDocName)
LOOP
XMLFind(:m_sDocName, CParagraph::CST_TAG , ...
XMLTag + XMLChildItem + XMLContinue, XMLExact)
IF XMLFound(:m_sDocName) = True THEN
XMLDelete (:m_sDocName)
ELSE
BREAK
END
END
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|