[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ftpapi] How to get the value?



Hi,

 

First, the biggest reason is in-experience in using xml-into and %xml.

The old-style way was just because in this particular case it seemed easier, for me.

Also, my experience in parsing XML is limited, so the structure of having elements and attributes with values and data is new to me.

 

When I was parsing using the old way, here’s what I did:

    D tExtension      c                   '/Extension'

    D tExtField       c                   '/ExtensionField'

if path = tResponse + tExtension;

 

         if name = iExtField;

 

           count = 1;

           dow http_nextXmlAttr(attrs: count: attrname: attrval);

             if attrname <> ' ';

               x += 1;

               gDS_response.extensionFieldName(x) = attrname;   = name

               gDS_response.extensionFieldValue(x) = attrval;   = "Sales Branch"

             endif;

           enddo;

 

endif;

 

Based on your question, “why can’t I get to the information” is simply because I couldn’t figure that out.

I am missing something, I just don’t know what and I was just curious to see if someone could guide me.

 

But, that’s OK, with the excellent description I got below I am sure I will get this done.

 

Thank you!

 

From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx <ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx> On Behalf Of Scott Klement
Sent: Thursday, January 30, 2020 1:23 PM
To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [Ftpapi] How to get the value?

 

Hello,

I don't understand.

First of all, why do you prefer to use the old-style http_url_post_xml() routine with its XML parser?  Most people would say this is the "hard way"?

But, if you do prefer that...  then what is the problem?  Why can't you get the information you need?

-SK

 

On 1/29/2020 1:01 PM, Frank Broome wrote:

Thank you very much for your response and example!

I suspected that the solution was to create a data-structure like this and then parse it using xml-into.

 

Originally I was posting the xml using:

lRC= http_url_post_xml(

             gReqURL

             : %addr(lXML)

             : lLenXML

             : %paddr(lcl_startOfElement)

             : %paddr(lcl_endOfElement)

             : *NULL

             : HTTP_TIMEOUT

             : HTTP_USERAGENT

             : gContentType);  

 

And I was just hoping to be able to get to the data using the built-in parser.

 

Again, thank you for your help, it’s really appreciated.

 

Best regards,

Frank

From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx <ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx> On Behalf Of Rainer Ross
Sent: Wednesday, January 29, 2020 1:01 AM
To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [Ftpapi] How to get the value?

 


Hi Frank,

here is the solution

         ctl-opt main(main) dftactgrp(*no) option(*nounref);
      //------------------------------------------------------------------//
      //                                                                  //
      // Example with datasubf=data                                       //
      //                                                                  //
      //-----------------                                                 //
      // R.Ross 01.2020 *                                                 //
      //------------------------------------------------------------------//
      // Array XML-File                                                   //
      //------------------------------------------------------------------//

         dcl-ds  Extension             qualified inz;
                  ExtensionField       likeds(ExtensionField) dim(3);
                  cnt_ExtensionField   uns(10);
         end-ds;

         dcl-ds  ExtensionField        qualified;
                  Name                 char(30);
                  Data                 char(30);
         end-ds;

      //------------------------------------------------------------------//
      // Main                                                             //
      //------------------------------------------------------------------//
         dcl-proc main;

         dcl-s   LocData     varchar(1000);
         dcl-s   LocOpt      varchar(256);

           LocOpt = 'doc=string +
                     case=any allowextra=yes +
                     countprefix=cnt_ +
                     datasubf=data +
                     allowmissing=yes';               // XML-Options

           LocData =
            '<Extension extensionTemplate="PARTNER_HEADER">' +
             '<ExtensionField name="Sales Branch">IT</ExtensionField>' +
             '<ExtensionField name="GLA Attached">N</ExtensionField>' +
             '<ExtensionField name="Inside Sales Rep">UNG</ExtensionField>' +
            '</Extension>';

           xml-into Extension %xml(LocData:LocOpt);

         end-proc;
      //------------------------------------------------------------------//


and the debugview

cid:image001.png@01D5D772.4DD07B90

Am 29.01.2020 um 01:05 schrieb Frank Broome:

Everyone,

 

Here’s a challenge for you all.

 

I have to parse an XML string that partly looks this.

You would say that ‘ExtensionField’ has attribute ‘name’ and that “Sales Branch” is the value.

However if you look closely you can see that the actual value is ‘IT’ (for “Sales Branch”).

I have never seen this combination of elements, attributes and its values before.

 

<Extension extensionTemplate="PARTNER_HEADER">

        <ExtensionField name="Sales Branch">IT</ExtensionField>

        <ExtensionField name="GLA Attached">N</ExtensionField>

        <ExtensionField name="Inside Sales Rep">UNG</ExtensionField>

    </Extension>

 

When I parse the XML I can get to the attribute “name” and value “Sales Branch”, but I can’t get to ‘IT’.

Maybe I am just not interpreting the XML correctly and should use a different procedure, but I can’t think of what that could be.

 

Personally I don’t think I can get to the values using the parser, but I would love for someone to prove me wrong.

 

Any ideas are welcome!

 

Best regards,

Frank

 

 

Disclaimer

The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.

This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business. Providing a safer and more useful place for your human generated data. Specializing in; Security, archiving and compliance. To find out more
Click Here.








 

 

Disclaimer

The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.

This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business. Providing a safer and more useful place for your human generated data. Specializing in; Security, archiving and compliance. To find out more
Click Here.





Disclaimer

The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.

This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business. Providing a safer and more useful place for your human generated data. Specializing in; Security, archiving and compliance. To find out more Click Here.

-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi