Progress - apertura de archivo xml

   
Vista:

apertura de archivo xml

Publicado por miguel gutierrez (2 intervenciones) el 05/12/2013 22:57:47
Buenas tardes. Alguien puede decir como abro un archivo xml para manejarlo como una cadena de texto
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Marcelo

apertura de archivo xml

Publicado por Marcelo (8 intervenciones) el 06/12/2013 11:37:53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**************************************************************************************************************
hola miguel, este es un ejemplo que encontre en Progress Talk, espero poder ayudarte, saludos.
*************************************************************************************************************/
 
/* e-outcus.p - Export the Customer table to an xml file*/
DEFINE VARIABLE hDoc AS HANDLE.
DEFINE VARIABLE hRoot AS HANDLE.
DEFINE VARIABLE hRow AS HANDLE.
DEFINE VARIABLE hField AS HANDLE.
DEFINE VARIABLE hText AS HANDLE.
DEFINE VARIABLE hBuf AS HANDLE.
DEFINE VARIABLE hDBFld AS HANDLE.
DEFINE VARIABLE i AS INTEGER.
CREATE X-DOCUMENT hDoc.
CREATE X-NODEREF hRoot.
CREATE X-NODEREF hRow.
CREATE X-NODEREF hField.
CREATE X-NODEREF hText.
hBuf = BUFFER code_mstr:HANDLE.
/*set up a root node*/
hDoc:CREATE-NODE(hRoot,"CODEMSTR","ELEMENT").
hDoc:APPEND-CHILD(hRoot).
 
FOR EACH CODE_mstr WHERE CODE_fldname MATCHES "pt_part_type":
hDoc:CREATE-NODE(hRow,"CODEMSTR","ELEMENT"). /*create a row node*/
hRoot:APPEND-CHILD(hRow). /*put the row in the tree*/
hRow:SET-ATTRIBUTE("CODE_FLDNAME",STRING(CODE_fldname)).
/*hRow:SET-ATTRIBUTE("Code_Value",CODE_value).*/
/*Add the other fields as tags in the xml*/
 
REPEAT i = 1 TO hBuf:NUM-FIELDS:
hDBFld = hBuf:BUFFER-FIELD(i).
IF hDBFld:NAME = "code_fldname" THEN NEXT.
/*create a tag with the field name*/
hDoc:CREATE-NODE(hField, hDBFld:NAME, "ELEMENT").
/*put the new field as next child of row*/
hRow:APPEND-CHILD(hField).
/*add a node to hold field value*/
hDoc:CREATE-NODE(hText, "", "TEXT").
 
/*attach the text to the field*/
hField:APPEND-CHILD(hText).
hText:NODE-VALUE = STRING(hDBFld:BUFFER-VALUE).
END.
END.
/*write the XML node tree to an xml file*/
hDoc:SAVE("file","d:\code.xml").
DELETE OBJECT hDoc.
DELETE OBJECT hRoot.
DELETE OBJECT hRow.
DELETE OBJECT hField.
DELETE OBJECT hText.
 
/***** Kishor Chari, Apr 16, 2009 ****/
 
 
 
/* e-incus.p - Import the Customer table from an xml file*/
DEFINE VARIABLE hDoc AS HANDLE.
DEFINE VARIABLE hRoot AS HANDLE.
DEFINE VARIABLE hTable AS HANDLE.
DEFINE VARIABLE hField AS HANDLE.
DEFINE VARIABLE hText AS HANDLE.
DEFINE VARIABLE hBuf AS HANDLE.
DEFINE VARIABLE hDBFld AS HANDLE.
DEFINE VARIABLE i AS INTEGER.
DEFINE VARIABLE j AS INTEGER.
 
/*so we can create new recs*/
DEFINE TEMP-TABLE CODEMSTR LIKE CODE_mstr.
CREATE X-DOCUMENT hDoc.
CREATE X-NODEREF hRoot.
CREATE X-NODEREF hTable.
CREATE X-NODEREF hField.
CREATE X-NODEREF hText.
 
hBuf = BUFFER Codemstr:HANDLE.
 
/*read in the file created in the last example*/
hDoc:LOAD("file", "d:\code.xml", FALSE).
hDoc:GET-DOCUMENT-ELEMENT(hRoot).
/*read each CodeMstr from the root*/
 
REPEAT i = 1 TO hRoot:NUM-CHILDREN:
hRoot:GET-CHILD(hTable,i).
CREATE Codemstr.
/*get the fields given as attributes*/
CODE_fldname = hTable:GET-ATTRIBUTE("CODE_FLDNAME").
 
/*get the remaining fields given as elements with text*/
REPEAT j = 1 TO hTable:NUM-CHILDREN:
hTable:GET-CHILD(hField,j).
IF hField:NUM-CHILDREN < 1 THEN NEXT.
/*skip any null value*/
hDBFld = hBuf:BUFFER-FIELD(hField:NAME).
hField:GET-CHILD(hText,1).
/*get the text value of the field*/
hDBFld:BUFFER-VALUE = hTEXT:NODE-VALUE.
END.
END.
DELETE OBJECT hDoc.
DELETE OBJECT hRoot.
DELETE OBJECT hTable.
DELETE OBJECT hField.
DELETE OBJECT hText.
/* show data made it by displaying temp-table */
FOR EACH codemstr:
DISPLAY codemstr.
END.
 
 
/************* Kishor Chari, Apr 16, 2009  *********/
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar