PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Principle for handling an XML document
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
Principle for handling an XML document
Versions 17 and later
iPhone/iPad These functions are now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad These functions are now available for the iPhone/iPad applications.
iPhone/iPad These functions are now available for the iPhone/iPad applications.
Versions 21 and later
Universal Windows 10 App This feature is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This feature is now available in Universal Windows 10 App mode.
Universal Windows 10 App This feature is now available in Universal Windows 10 App mode.
Two methods can be used to handle an XML document:
  1. Versions 15 and later
    Using an xmlDocument variable (Recommended method). This method allows you to use a XSD file.
    Several types of specific variables are available:
    Versions 15 and later
    xmlAttribute
    New in version 15
    xmlAttribute
    xmlAttribute
    The xmlAttribute type is used to handle the attributes of a node in an XML document.
    Versions 15 and later
    xmlDocument
    New in version 15
    xmlDocument
    xmlDocument
    The xmlDocument type is used to handle an XML file.
    Versions 15 and later
    xmlNamespace
    New in version 15
    xmlNamespace
    xmlNamespace
    The xmlNamespace type is used to handle the XML namespace of a node attribute in an XML document.
    Versions 15 and later
    xmlNode
    New in version 15
    xmlNode
    xmlNode
    The xmlNode type is used to handle a node of an XML document.

    Several specific functions can be used to handle the xmlDocument variables
    Versions 09 and later
    XMLBuildString
    New in version 09
    XMLBuildString
    XMLBuildString
    Retrieves and formats the content of an XML document (created by XMLDocument and modified by the XML functions).
    Versions 15 and later
    XMLOpen
    New in version 15
    XMLOpen
    XMLOpen
    Loads an XML document from a file, a URL or a string in an xmlDocument variable.
    Versions 15 and later
    XMLSave
    New in version 15
    XMLSave
    XMLSave
    Saves an XML document in a file.
    Versions 15 and later
    XMLValidDocument
    New in version 15
    XMLValidDocument
    XMLValidDocument
    Validates an XML document from an XSD schema.
    New in version 15
    Using an xmlDocument variable (Recommended method). This method allows you to use a XSD file.
    Several types of specific variables are available:
    Versions 15 and later
    xmlAttribute
    New in version 15
    xmlAttribute
    xmlAttribute
    The xmlAttribute type is used to handle the attributes of a node in an XML document.
    Versions 15 and later
    xmlDocument
    New in version 15
    xmlDocument
    xmlDocument
    The xmlDocument type is used to handle an XML file.
    Versions 15 and later
    xmlNamespace
    New in version 15
    xmlNamespace
    xmlNamespace
    The xmlNamespace type is used to handle the XML namespace of a node attribute in an XML document.
    Versions 15 and later
    xmlNode
    New in version 15
    xmlNode
    xmlNode
    The xmlNode type is used to handle a node of an XML document.

    Several specific functions can be used to handle the xmlDocument variables
    Versions 09 and later
    XMLBuildString
    New in version 09
    XMLBuildString
    XMLBuildString
    Retrieves and formats the content of an XML document (created by XMLDocument and modified by the XML functions).
    Versions 15 and later
    XMLOpen
    New in version 15
    XMLOpen
    XMLOpen
    Loads an XML document from a file, a URL or a string in an xmlDocument variable.
    Versions 15 and later
    XMLSave
    New in version 15
    XMLSave
    XMLSave
    Saves an XML document in a file.
    Versions 15 and later
    XMLValidDocument
    New in version 15
    XMLValidDocument
    XMLValidDocument
    Validates an XML document from an XSD schema.
    Using an xmlDocument variable (Recommended method). This method allows you to use a XSD file.
    Several types of specific variables are available:
    Versions 15 and later
    xmlAttribute
    New in version 15
    xmlAttribute
    xmlAttribute
    The xmlAttribute type is used to handle the attributes of a node in an XML document.
    Versions 15 and later
    xmlDocument
    New in version 15
    xmlDocument
    xmlDocument
    The xmlDocument type is used to handle an XML file.
    Versions 15 and later
    xmlNamespace
    New in version 15
    xmlNamespace
    xmlNamespace
    The xmlNamespace type is used to handle the XML namespace of a node attribute in an XML document.
    Versions 15 and later
    xmlNode
    New in version 15
    xmlNode
    xmlNode
    The xmlNode type is used to handle a node of an XML document.

    Several specific functions can be used to handle the xmlDocument variables
    Versions 09 and later
    XMLBuildString
    New in version 09
    XMLBuildString
    XMLBuildString
    Retrieves and formats the content of an XML document (created by XMLDocument and modified by the XML functions).
    Versions 15 and later
    XMLOpen
    New in version 15
    XMLOpen
    XMLOpen
    Loads an XML document from a file, a URL or a string in an xmlDocument variable.
    Versions 15 and later
    XMLSave
    New in version 15
    XMLSave
    XMLSave
    Saves an XML document in a file.
    Versions 15 and later
    XMLValidDocument
    New in version 15
    XMLValidDocument
    XMLValidDocument
    Validates an XML document from an XSD schema.
  2. Using a string variable to store the XML document. Then, the XML document can be handled by the different XML functions.
    The following functions are used to manage the XML documents:
    TextToXMLConverts a character string in ANSI format into a character string in XML format.
    XMLAddAttributeAdds an attribute into an XML document.
    XMLAddChildAdds a child tag into an XML document.
    XMLBuildStringRetrieves and formats the content of an XML document (created by XMLDocument and modified by the XML functions).
    XMLCancelSearchCancels the search performed by XMLFind.
    XMLChildPositions on the first child element of current element.
    XMLChildExistSpecifies whether the current tag has children corresponding to the sought type (tag, attribute, ...).
    XMLCloseCloses an XML document created by XMLDocument.
    XMLDataReturns the value of current element (tag or XML attribute) or the value of one of its attributes.
    XMLDeleteDeletes the current element (as well as the entire branch) from an XML document.
    XMLDocumentCreates a new XML document.
    XMLElementNameReturns the name of current element (tag or attribute).
    XMLElementTypeReturns the type of current element (tag or attribute).
    XMLExecuteXPathRuns an XPATH query:
    • in an XML document.
    • in an xmlDocument variable.
    XMLExtractDocumentCreates a new XML document from an existing XML document.
    XMLExtractStringExtracts the content of a tag found in an XML document.
    XMLFindPerforms a search in an XML document.
    XMLFindNamespaceByNameFinds an XML namespace according to its XML node and in the parents of the node.
    XMLFindNamespaceByURIFinds an XML namespace from its URI (Universal Resource Identifier) in a node and in the parents of this node.
    XMLFirstPositions on the first element (tag or attribute) in the current tree level.
    XMLFoundChecks whether the current element corresponds to the current browse or to the current search.
    XMLInsertDocumentInserts the current XML tag found in an XML document into another XML document.
    XMLInsertElementInserts an XML element (tag or attribute) into an XML document.
    XMLLastPositions on the last element (tag or attribute) of the current tree level.
    XMLModifyModifies the content of the current element found in the XML document.
    XMLNamespaceReturns the prefix of the namespace associated with the current tag in an XML document.
    XMLNamespaceURIReturns the URI of the namespace associated with the current tag in an XML document.
    XMLNextPositions on the next element (tag or attribute).
    XMLOpenLoads an XML document from a file, a URL or a string in an xmlDocument variable.
    Versions 23 and later
    XMLOpenReader
    New in version 23
    XMLOpenReader
    XMLOpenReader
    Creates a reader used to read an XML document without loading it in memory.
    XMLOutUsed to find out whether the element (tag or attribute) on which we want to be positioned is outside the XML document.
    XMLParentPositions on the parent element of current element (tag or attribute).
    XMLParentNameReturns the name of parent tag for the current element (tag or attribute).
    XMLPathReturns the current position in the document in XPATH format.
    XMLPreviousPositions on the previous element (tag or attribute).
    XMLReadReturns the value of an XML element or the value of the attribute for an XML element.
    XMLRenameRenames the current element (tag or attribute) in an XML document.
    XMLRestorePositionRestores the previously saved context of an XML document.
    XMLResultReturns the result of a calculation XPath query.
    XMLRootPositions on the root tag of an XML document.
    XMLSaveSaves an XML document in a file.
    XMLSavePositionStores the current position in the XML document.
    XMLToTextConverts a character string in XML format into a standard character string.
    XMLValidDocumentValidates an XML document from an XSD schema.
    XMLValidNodeValidates an XML node, its children and its attributes from its description in the XSD schema linked to the XML document.
    XMLWriteCreates or modifies the value of an XML element or the value of the attribute for an XML element.
Some functions are also linked to the management of XML:
Versions 09 and later
HExportXML
New in version 09
HExportXML
HExportXML
Exports the records found in a data file (HFSQL or OLE DB), view or query into an XML file.
Versions 09 and later
HImportXML
New in version 09
HImportXML
HImportXML
Imports an XML file into a data file in HFSQL Classic or Client/Server format (data file described in the data model editor or declared by HDeclare, HDeclareExternal or HDescribeFile).
Versions 09 and later
HRecordToXML
New in version 09
HRecordToXML
HRecordToXML
Retrieves the structure and the value of the current record and exports them into a character string in XML format.
Versions 09 and later
J2EERunXML
New in version 09
J2EERunXML
J2EERunXML
Runs a procedure on a server of J2EE XML Web services.
Versions 10 and later
LooperToXML
New in version 10
LooperToXML
LooperToXML
Creates an XML file with the data found in a looper (browsing looper or memory looper).
Versions 09 and later
SOAPRunXML
New in version 09
SOAPRunXML
SOAPRunXML
Runs a procedure on a SOAP server.
Versions 09 and later
TableToXML
New in version 09
TableToXML
TableToXML
Creates an XML file from the data found in a Table or TreeView Table control .
Related Examples:
Reading and writing in XML format Unit examples (WINDEV): Reading and writing in XML format
[ + ] Using the XMLxxx functions to:
- Create an XML document
- Read an XML document
XML parser Unit examples (WINDEV): XML parser
[ + ] Studying the content of an XML file via the XMLxxx functions of WINDEV
WD Syntactic Coloring Training (WINDEV): WD Syntactic Coloring
[ + ] This example proposes a base class used to perform a standard syntactic coloring on some text.
This coloring is based on a rough analysis of the lemmes found in a text in order to identify the elements of a programming language for instance.
It can be overloaded or derived in order to customize the system and the coloring language.
This example is used to color SQL code and XML code but it can be extended to color other languages or other text formats.
WD Multimedia Complete examples (WINDEV): WD Multimedia
[ + ] This example explains how to play videos (AVI, MPEG, and so on), sounds (AUDIO CD, MP3, WAV) and animations (Flash) with the WLanguage functions. The following topics are presented in this example:
1/ how to handle the sounds and the videos in WLanguage
2/ how to exploit a "Flash" animation
3/ how to clip windows
4/ how to manage a playlist
5/ how to generate playlists with the XML functions
Summary of the example supplied with WINDEV:
This example is used to read all types of multimedia files. It manages a playlist that can be modified, saved and opened.
This example helps you include multimedia resources in your applications.
Minimum required version
  • Version 9
This page is also available for…
Comments
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
Dec. 15 2017
Exemplo Xml
//Ler um Xml de Nota Fiscal Eletronica
//Pegar Numero da Nota e data emissao
//Pegar dados dos Itens dos Produtos

//Ler Xml, Colocar dados e Preencher tabela com Produtos
xml_nfe is a xmlDocument = XMLOpen (edT_xml,fromString)
Trace("Operacao:"+xml_nfe.NFe.infNFe.natOp) //Mostrar na Tela natOp
Trace("Emitente:"+xml_nfe.NFe.infNFe.emit.xNome)
Trace("infnfe Id:"+xml_nfe.NFe.infNFe..Attribut[1])
Trace("infnfe Versao:"+xml_nfe.NFe.infNFe..Attribut[2])
SAI_NumeroNota=xml_nfe.NFe.infNFe.ide.nNF
_data_string is string=xml_nfe.NFe.infNFe.ide.dhEmi
_data is Date=""
_data..Year=_data_string[[1 TO 4]]
_data..Month=_data_string[[6 TO 7]]
_data..Day=_data_string[[9 TO 10]]
SAI_data_emissao=_data
TableDeleteAll(TABLE_itens_nota) // Limpa Tabela
det is xmlNode
FOR EACH det OF xml_nfe.NFe.infNFe on det
Trace("ocor"+det..Occurrence) // Quantos itens tem
Trace("nItem"+det..Attribut[1]) // Mostrar o que tem nItem
Trace("Imposto vTotTrib:"+det.imposto.vTotTrib)
Trace("Produto:"+det.prod.xProd)
TableAddLine(TABLE_itens_nota) // Adicionando a tabela
n_ocorrencia is int= TABLE_itens_nota..Occurrence //vou ter o numero atual linha tabela
TABLE_itens_nota.COL_Iten[n_ocorrencia]=det..Attribut[1]
TABLE_itens_nota.COL_Produto[n_ocorrencia]=det.prod.xProd
TABLE_itens_nota.COL_Valor_Tributo[n_ocorrencia]=det.imposto.vTotTrib
END

// Blog com video e Exemplo
http://windevdesenvolvimento.blogspot.com.br/2017/02/aula-1067-windev-xml-9-ler-um-xml-de.html

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

De matos
Feb. 21 2017