Visualizar XML
Enviado: 01 Out 2016 10:46
Alguém chegou a montar alguma coisa pra visualizar XML?
Tentei assim, mas é pouco ainda.
Nota: seria pra visualizar sem existir arquivo XML em disco.
Tentei assim, mas é pouco ainda.
Código: Selecionar todos
#define NODE_ABRE 1
#define NODE_FECHA 2
PROCEDURE Main
LOCAL cText, cText2, cLetra, nAbreFecha, aTextList := {}, oElement, nCol := 0, nAbreFechaAnterior := 0
SetMode( 40, 100 )
SetColor( "W/B,N/W,,,W/B" )
CLS
cText := MemoRead( "test.xml" )
cText2 := ""
FOR EACH cLetra IN cText
IF cLetra == "<"
nAbreFecha := iif( Substr( cText, cLetra:__EnumIndex + 1, 1 ) != "/", NODE_ABRE, NODE_FECHA )
IF nAbreFecha == NODE_ABRE .OR. ( nAbreFecha == NODE_FECHA .AND. nAbreFechaAnterior == NODE_FECHA )
AAdd( aTextList, cText2 )
cText2 := ""
ENDIF
nAbreFechaAnterior := nAbreFecha
ENDIF
cText2 += cLetra
NEXT
IF ! Empty( cText2 )
AAdd( aTextList, cText2 )
ENDIF
FOR EACH oElement IN aTextList
nCol -= iif( Left( oElement, 2 ) == "</", 3, 0 )
oElement := Pad( Space( nCol ) + oElement, 98 )
nCol += iif( ! "</" $ oElement .AND. ! "/>" $ oElement, 3, 0 )
NEXT
CLS
AChoice( 1, 1, 39, 99, aTextList )
RETURN