Hi, I have a xml search:
xmlNode := xmlIter:Find('xCpl')
Compl_Rem := xmlNode:cData
If not found xCpl in xml file my program hangs. How I can avoid this?
Thanks in advance.
karinha wrote:Wanderson, veja se este exemplo ajuda:
http://fivewin.com.br/index.php?/topic/ ... -xml-nf-e/
abs,
#include "FiveWin.ch"
#include "fileio.ch"
#include "hbxml.ch"
FUNCTION Main()
LOCAL hFile, cXml, cFileName:="TEST.XML"
LOCAL xmlDoc, xmlIter , xmlNode, cNode, cAttrib, cValue, oCampo, oConteudo
IF .NOT. FILE( cFileName )
MsgInfo( "Arquivo Não Encontrado !!!","Atenção" ) // nome do arquivo
cFileName := cGetFile( "XML File (*.Xml)|*.Xml|","Selecione arquivo XML da NFe ",curdir())
IF .NOT. FILE( cFileName )
RETURN NIL
ENDIF
ENDIF
cNode := NIL
cAttrib := NIL
cValue := NIL
hFile := FOpen( cFileName )
xmlDoc := TXmlDocument():New( hFile )
IF xmlDoc:nStatus != HBXML_STATUS_OK
Msginfo( "Erro ao Ler Arquivo .XML" )
RETURN NIL
ENDIF
xmlIter := TXmlIterator():New( xmlDoc:oRoot )
xmlNode := xmlIter:Find()
DO WHILE xmlNode != NIL
SYSREFRESH()
IF .NOT. EMPTY( xmlNode:cData )
IF SUBS( xmlNode:cData,1,1 ) # "<"
oCampo := xmlNode:cName
oConteudo := xmlNode:cData
ENDIF
ELSE
oCampo := xmlNode:cName
ENDIF
? oCampo, oConteudo
xmlNode := xmlIter:Next() // joga pro proximo campo
ENDDO
RETURN NIL
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 44 guests