PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
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.
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.
<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.
Business / GUI classification : Neutral code
Component : wd250xml.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Video XMLExtractString
https://youtu.be/7BnHDQJMbcE

https://windevdesenvolvimento.blogspot.com/2019/03/dicas-2032-windev-xml-020.html

EDT_XML=[
<retConsStatServ xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00">
<tpAmb>2</tpAmb>
<verAplic>RS201805211008</verAplic>
<cStat>107</cStat>
<xMotivo>Servico em Operacao</xMotivo>
<cUF>43</cUF>
<dhRecbto>2019-03-02T16:04:06-03:00</dhRecbto>
<tMed>1</tMed>
</retConsStatServ>
]
EDT_RESULTADO=XMLExtractString(EDT_XML,"xMotivo")

amarildo
03 Mar. 2019
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
15 Jan. 2016