Si sabes como mejorarlo, se agradece tu colaboración para que asi tengamos una función de lectura genérica de un XML
xmlreader.prg
- Code: Select all Expand view
- #include "FiveWin.ch"
function Main()
local hFile := FOpen( "test.xml" )
Local oMnuXml := TXmlDocument():New( hFile )
Local oXmlNode := oMnuXml:FindFirst( "Header" )
Local oXmlIter := TXmlIterator():New( oXmlNode ), oTagActual, cAttribute
while .T.
oTagActual = oXmlIter:Next()
If oTagActual != nil
? oTagActual:cName, oTagActual:cData
Else
Exit
Endif
End
oXmlNode = oMnuXml:FindFirst( "Detail" )
oXmlIter = TXmlIterator():New( oXmlNode )
while .T.
oTagActual = oXmlIter:Next()
If oTagActual != nil
MsgInfo( oTagActual:cName, oTagActual:cData )
HEval( oTagActual:aAttributes, { | cKey, cValue | MsgInfo( cKey, cValue ) } )
// MsgInfo( ValType( oTagActual:aAttributes ) )
// for each cAttribute in oTagActual:aAttributes
// MsgInfo( cAttribute, oTagActual:GetAttribute( cAttribute ) )
// next
Else
Exit
Endif
End
FClose( hFile )
return nil