Kbase P75487: How to insert namespaces in XML document nodes ?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  06/04/2004 |
|
Status: Unverified
GOAL:
How to insert namespaces in XML document nodes ?
GOAL:
How can I get something like:
<CustomerEnvelop xmlns:xsd=http://www.w3.org/2000/xmlns/XMLSchema>
FIX:
Treat the namespace as a node attribute. See following example.
DEF VAR hR AS HANDLE.
DEF VAR hN AS HANDLE.
DEF VAR hN2 AS HANDLE.
DEF VAR cURI AS CHARACTER.
DEF VAR cxURI AS CHARACTER.
cURI = "http://www.w3.org/2000/xmlns/XMLSchema".
cxURI = "http://www.w3.org/2000/xmlns/XMLSchema-Instance".
DEF VAR vi AS INTEGER.
CREATE X-DOCUMENT hR .
CREATE X-NODEREF hN .
CREATE X-NODEREF hN2 .
hR:ENCODING = 'utf-8'.
hR:CREATE-NODE(hN, 'CustomerEnvelop' ,'Element' ).
hN:SET-ATTRIBUTE( "xmlns:xsd", cURI ) .
hN:SET-ATTRIBUTE( "xmlns:xsi", cxURI ) .
hR:APPEND-CHILD( hN ).
hR:CREATE-NODE(hN2, 'Customers' ,'Element' ).
hN:APPEND-CHILD( hN2 ).
FOR EACH customer NO-LOCK
vi = 1 TO 3 :
hR:CREATE-NODE( hN, "Customer", "ELEMENT" ).
hN2:APPEND-CHILD( hN ).
hN:SET-ATTRIBUTE( "Name", customer.NAME ).
hN:SET-ATTRIBUTE( "CustNum", string( customer.custNum ) ).
END.
hR:SAVE( "file", "tsxml.txt" ).
OS-COMMAND SILENT VALUE( "notepad.exe tsxml.txt" ).