If you know how to improve it, lets improve it to get a generic XML reader function
xmlread.prg
- Code: Select all Expand view RUN
- #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