Results 1 to 10 of 26

Thread: xml

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #15
    Join Date
    Feb 2009
    Location
    Colombia
    Posts
    2,509

    Default Re: xml

    hi Focus

    Hi Focus:
    I need your wisdom. I need to read the attached file. I have developed this code and I read the "invoice" nodes but I need to go through it and I have not been able to read the elements, if you help me with some guidance I would appreciate it.

    The last problem I managed to solve, it was simpler, it uses several Namespaces.

    Code:
      procedure XMLREAD
                Handle  hoXML hoRoot hoElemto hoHijo hoHijo2 hoHijo3 hoList
                Handle hoContact hoAddr hoRecord hoNode hoNextNode
                Boolean bOk
                String  sFile sNs sData sInvoiceAuthorization sAttributeName
                Integer i iItems iItemsCab iItemsDet iItemsImp iLinea
                 
             
                
                 Move "C:\temporal\face649.XML" to sFile
                
                 Move  'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' to sns// x'mlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'"  to sNs
                 Append sNs ' xmlns:xsi="http://uri.etsi.org/01903/v1.4.1#" '
                 Append sNs ' xmlns:ds="http://www.w3.org/2000/09/xmldsig#" '
                 Append sNs ' xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" '
                 
                 Move (ResizeArray(vtCabezaFactura,0)) to vtCabezaFactura
         
                 Get Create (RefClass(cXMLDOMDocument)) to hoXML
               
                 Set psSelectionNamespaces of hoXML to 'xmlns:sts="dian:gov:co:facturaelectronica:Structures-2-1" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"'
                  
               
                 Set psDocumentName    of hoXML to sFile
                 Set pbValidateOnParse of hoXML to True
                  Get LoadXMLDocument of hoXML to bOK 
                
                 If (bOK) Begin
                 Get DocumentElement of hoXML to hoRoot
                 Get psNodeName of hoRoot   to sAttributeName
                 Get FirstChild of hoRoot to hoNode // get the first node
                  While (hoNode<>0)
                     Get psNodeName of hoNode                          to sAttributeName
                     Increment iLinea
                      Send ShowInformation hoNode iLinea sNs
                     Get NextSibling of hoNode to hoNextNode // now get next sibling node
                     Send Destroy of hoNode     // Important: get rid of the previous node object
                     Move hoNextNode to hoNode
                 Loop
                   
              End_Procedure
              
              Procedure ShowInformation Integer hoNode Integer iLineCount String sNs
                    String sName
                    Integer iType
                    // If the node is an element (e.g. Customer), get the element's nodename and the attribute value for NAME
                    // skip all non-element nodes
                    Get piNodeType of hoNode to iType
                    If (iType = NODE_ELEMENT) Begin
                       Get AttributeValue of hoNode "cbc:ID" to sName
                       Get AttributeValueNS of hoNode sNs "cbc:ID" to sName
    
                       Showln iLineCount ": Node is [" (psNodeName(hoNode)) "] Name is [" sName "]" 
                    End
            End_Procedure
    Edgar
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •