MsgInfo( GetStringFromXMl('<xMotivo>','</xMotivo>', cXML ) )
Function GetStringFromXMl( cIni, cEnd, cString )
Local nIni:=At( cIni, cString ) + Len( cIni )
Local nFim:=At( cEnd, cString ) - nIni
Return Alltrim( Substr( cString, nIni, nEnd ) )
#include "fivewin.ch"
#include "fileio.ch"
#include "hbxml.ch"
PROCEDURE Main()
public ownd
define window ownd title "XML File"
activate window ownd on init (Abrir_Xml("demo.xml"))
RETURN
Function Abrir_Xml(cFileName)
LOCAL hFile, cXml,xmlDoc, xmlIter, xmlNode, cNode, cAttrib, cValue, cData
hFile := FOpen( cFileName )
xmlDoc := TXmlDocument():New( hFile )
IF xmlDoc:nStatus != HBXML_STATUS_OK
MsgStop("Falha no arquivo XML ","ERRO Arquivo XML")
RETURN
ENDIF
xmlIter := TXmlIterator():New( xmlDoc:oRoot )
xmlNode := xmlIter:Find()
DO WHILE xmlNode != NIL
msginfo( xmlNode:cName ,"Field name")
msginfo( xmlNode:cData ,"VAlue from fieldr")
xmlNode := xmlIter:Next()
ENDDO
Return
<?xml version="1.0" encoding="iso-8859-2"?>
<language lang="pt-br">
<Xml id="2.21">
<data>26/12/2010</data>
<xharbour>xHarbour 1.2.1</xharbour>
<fivewin>Fivewin 10.11</fivewin>
<bcc>Borland 5.8.2</bcc>
<Filexml>OK</Filexml>
</Xml>
</language>
<emit>
<xNome>Lailton</xNome>
</emit>
<dest>
<xNome>Wanderson</xNome>
</dest>
cXML := StrTran( MemoRead( "demo.xml" ), CRLF )
cGrupoEmit := GetStringFromXMl('<emit>','</emit>', cXML )
cGrupoDest := GetStringFromXMl('<dest>','</dest>', cXML )
? "Emit", GetStringFromXMl('<xNome>','</xNome>', cGrupoEmit )
? "Dest", GetStringFromXMl('<xNome>','</xNome>', cGrupoDest )
lailton.webmaster wrote:It´s Utf8 you need convert, uf82ansi
HB_OemToAnsi( UTF8ToStr( cString ) )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 92 guests