PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Special cases
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
Returns the value of an XML element or the value of the attribute for an XML element.
Example
MyDoc is string = fLoadText("example.xml")
XMLDocument("DOM", MyDoc)
sFunctionName is string = XMLRead("DOM","/Example/Help/Function")
sFunctionType is string = XMLRead("DOM","Help/Function/@type")
sFunctionName2 is string = XMLRead("DOM","Help/Function[2]")
sImage is string = XMLRead("DOM","Help[2]/@image")
sImageType is string = XMLRead("DOM","/Example/Help[@image=""line.jpg""]/@format", "NotDefined")
XMLClose("DOM")
// Applies to the next XML document:
// <Example>
// <Help>
// <Function type="1">Read</Function>
// <Function>Write</Function>
// </Help>
// <Help image="line.jpg" format="jpg" />
// </Example>
Syntax
<Result> = XMLRead(<XML document> , <Path of element to read> [, <Not found>])
<Result>: Character string
  • Value of element or value of attribute,
  • Empty string ("") or value of <Not found> parameter in the following cases:
    • if the element was not found.
    • if the element has no value
    • if the XPath query is not a query for selecting records.
      In this case, the ErrorOccurred variable is set to True and ErrorInfo returns more details about the error.
<XML document>: Character string (with quotes)
Name of XML document where the reading will be performed. This document contains the XML code to study and it was created by XMLDocument.
<Path of element to read>: Character string (with quotes)
Can correspond to:
  • the path of the value to read in the XML file. Caution: the case is taken into account (lowercase and uppercase characters). To read the value of an attribute, the name of the attribute must be preceded by the "@" character.
  • the text of an XPath query to run. The XPath query must be a query for "selecting records". If several elements match the selection, the first element found is used.
If this path does not start with "/", the name of the root node is automatically added. If the XML document has no root, <Result> will correspond to <Not found>.
<Not found>: Optional character string (with quotes)
Text to return if the element was not found. This parameter corresponds to an empty string ("") by default.
Remarks

Special cases

  • XMLRead does not modify the current position in the document.
  • Several XML browse queries cannot be nested.
  • XMLRead must not be used with an XMLDocument variable. To read the content of an XMLDocument variable, use the "FOR EACH" syntax.
Component : wd240xml.dll
Minimum version required
  • Version 12
This page is also available for…
Comments
video ler xml
https://youtu.be/8mYz1NtRDRo
amarildo
25 Nov. 2018
LER ITEM XML
PROCEDURE ler_danfe_itens_impostos_xml()
documento is string = EDT_Xml_nfe
xml_nfe is a xmlDocument
xml_nfe=XMLOpen(documento,fromString)
det is xmlNode
_sequencia is int=0
FOR EACH det OF xml_nfe.nfeProc.NFe.infNFe on det
TableAddLine(TABLE_itens) // Adicionando a tabela
n_ocorrencia is int= TABLE_itens..Occurrence //vou ter o numero atual linha tabela
_sequencia++
TABLE_itens.COL_01_sequencia[n_ocorrencia]=_sequencia
TABLE_itens.COL_02_id_nota_fiscal_iten[n_ocorrencia]=0
TABLE_itens.COL_03_cProd[n_ocorrencia]=det.prod.cProd
TABLE_itens.COL_04_cEAN[n_ocorrencia]=det.prod.cEAN
TABLE_itens.COL_18_ICMS_ICMSSN_orig[n_ocorrencia]=det.imposto.ICMS..ChildNode[1].orig
TABLE_itens.COL_19_ICMS_ICMSSN_CST_CSOSN[n_ocorrencia]=det.imposto.ICMS..ChildNode[1].CST

END
//=================================

AULA 1307 WINDEV XML 017 - LER ITENS NOTA NFE

http://windevdesenvolvimento.blogspot.com.br/2017/12/aula-1307-windev-xml-017-ler-itens-nota.html

https://www.yout
De matos
15 Dec. 2017
PEGAR ITEN XML
LOOP
n_contador++
//mdfeProc/MDFe/infMDFe/infDoc/infMunDescarga/infNFe[1]/chNFe
//mdfeProc/MDFe/infMDFe/infDoc/infMunDescarga/infNFe[2]/chNFe
s_chNFe is string=XMLRead("XML","/mdfeProc/MDFe/infMDFe/infDoc/infMunDescarga/infNFe["+n_contador+"]/chNFe")

IF s_chNFe="" THEN
BREAK
ELSE
s_infDoc_chNFe+="CT-E "+s_chNFe+CR
END

END

// NESSE BLOG E VIDEO MOSTRO COMO PEGAR ITEN XML

http://windevdesenvolvimento.blogspot.com.br/2017/09/aula-1256-xml-016-itens-xml.html

https://www.youtube.com/watch?v=IqsKTY64ZO4

De matos
06 Sep. 2017
PEGAR ID NOTA XML
XMLDocument("XML",pXML)
XMLFind("XML",Null,XMLContinue+XMLChildItem)
s_ide_id_nota is string=XMLRead("XML","/mdfeProc/MDFe/infMDFe/@Id")
// VAI RETORNAR => MDFe43170800397887000101580010000000731000001825
s_ide_cUF is string=XMLRead("XML","/mdfeProc/MDFe/infMDFe/ide/cUF")
// VAI RETORNAR => 43
XMLClose("xml")

// BLOG COM VIDEO E EXEMPLO
http://windevdesenvolvimento.blogspot.com/2017/09/aula-1253-xml-013-ler.html

https://www.youtube.com/watch?v=MQ8M3kg43gI



De matos
02 Sep. 2017