Skip to Content
author's profile photo Former Member
Former Member

How to download xml file from http:// (url) and then parse it (istrem).

Hi,

how Can I resolve downloading xml file from http server (internet) and built istream -> parse xml file. I build istream from itab but i would like whole process solve in abap code because i just use function ws_upload. If i try use

create_istream_uri( 'http://www.edi.com/file.xml' ) it doesnt work. Till now I must download xml file from this url manualy a then use this function and parse it, .....

*CALL FUNCTION 'WS_UPLOAD'

  • EXPORTING

  • filename = lv_file_url

  • filetype = 'BIN'

  • IMPORTING

  • filelength = xml_table_size

  • TABLES

  • data_tab = xml_table

  • EXCEPTIONS

  • OTHERS = 11.

ixml = cl_ixml=>create( ).

streamfactory = ixml->create_stream_factory( ).

*istream = streamfactory->create_istream_itable( table = xml_table

  • size = xml_table_size ).

Thanks, zd.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 27, 2005 at 02:35 PM

    Hai triska,

    Check out the code from

    /people/thomas.jung3/blog/2005/07/01/bsp-create-a-weather-magnet-using-xml-feed-from-weathercom

    Adjust with the formating of the Blog.

    data: url type string. 
    data: t_url type string. 
    data: client type ref to if_http_client. 
    data: c_xml type string. 
    
    concatenate `http://xoap.weather.com/weather/local/` `` `47546` `?cc=*&prod=xoap&par=XXXXXXXXXX` `&key=XXXXXXXXXXXXXX` into url.
    
    ****Create the HTTP client call method 
    cl_http_client=>create_by_url 
    exporting 
    url = url 
    host_compatibility = abap_true 
    importing client = client 
    exceptions others = 1. 
    
    ****Make the call 
    client->send( ). 
    ****Receive the Response Object call method 
    client->receive 
    exceptions 
    http_communication_failure = 1 
    http_invalid_state = 2 
    http_processing_failed = 3 
    others = 4. 
    
    ****Get the response content in Character format 
    
    c_xml = client->response->get_cdata( ). 
    
    

    regards,

    Venkatesh

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.