PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
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
XMLExtractString (Function)
In French: XMLExtraitChaîne
Extracts the content of a tag found in an XML document. To perform more complex searches, use XMLDocument and XMLFind.
AndroidAndroid Widget Java In the XML code, the list of attributes is sorted in alphabetical order.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
Android This function is now available for the Android applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
Android This function is now available for the Android applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Android This function is now available for the Android 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.
Example
// Load the XML code
XMLSource is string = fLoadText("example.xml")
Result1 is string
i is int = 1

// Extract the XML code found in the first "<operation>" tag
Result1 = XMLExtractString(XMLSource, "operation", i)
WHILE Result1 <> ""
        Trace(Result1)
        i = i + 1
       // Extract the XML code found in the next "<operation>" tag
        Result1 = XMLExtractString(XMLSource, "operation", i)
END
Syntax
<Result> = XMLExtractString(<XML Code> , <Tag> [, <Subscript> [, <Search Options>]])
<Result>: Character string
  • Tag content.
  • Empty string (""):
    • if the tag is not found
    • if the tag does contains no XML code.
<XML Code>: Character string with quotes
XML code containing the tag.
PHP This code must be in ANSI format.
<Tag>: Character string with quotes
Name of tag whose content will be extracted.
<Subscript>: Optional integer
Subscript of tag (if the tag appears several times in the XML code). This parameter is set to 1 by default.
<Search Options>: Optional constant
Search options for the extraction:
XMLExact
(Default value)
The tag name is case sensitive for the search.
XMLIgnoreCaseThe tag name is not case sensitive for the search.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230xml.dll
Windows Mobile wp230xml.dll
Java wd230java.jar
Linux wd230xml.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Exemplo com XmlExtractString
//busca cep
_manda_Cep is int=SAI_cep_busca
(SAI_uf,SAI_cidade,SAI_bairro,SAI_tipo,SAI_rua)=busca_cep(_manda_Cep)
//----
PROCEDURE busca_cep(n_cep_recebe is int)
Resultadoxml is string=""
ok is boolean=HTTPRequest("http://cep.republicavirtual.com.br/web_cep.php?cep="+n_cep_recebe+"&formato=xml")
IF ok=True THEN
Resultadoxml=HTTPGetResult()
ELSE
Resultadoxml=""
Info("cep nao existe"+n_cep_recebe)
END
sNo_xml is string=XMLExtractString(Resultadoxml,"webservicecep")
suf is string=XMLExtractString(sNo_xml,"uf")
suf=Upper(remove_acento(suf))
sCidade is string=XMLExtractString(sNo_xml,"cidade")
sCidade=Upper(remove_acento(sCidade))
sBairro is string=XMLExtractString(sNo_xml,"bairro")
sBairro=Upper(remove_acento(sBairro))
sTipo is string=XMLExtractString(sNo_xml,"tipo_logradouro")
sTipo=Upper(remove_acento(sTipo))
sRua is string=XMLExtractString(sNo_xml,"logradouro")
sRua=Upper(remove_acento(sRua))
RESULT(suf,sCidade,sBairro,sTipo,sRua)

// Blog com video e exemplo completo

http://windevdesenvolvimento.blogspot.com.br/2016/01/windev21-curso-225-cep-republica.html
De matos AMARILDO
Jan. 15 2016