Read XML data from URL

Hello,
Greetings to everybody. I am having a problem reading or capturing the XML data being send by a URL and the said URL does not send the XML data as a file, but it just send it out as data.
I do not know how to capture the said xml data from the said given URL. Please Help. Thank You, very, very, very much.
Cheers !
vins
[email protected]

public String getXml(String strURL){
URL url  = null;
URLConnection conn = null;
BufferedReader in = null;
try{
    url = new URL(strURL);
    conn = url.openConnection();
    in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String line = null;
    StringBuffer xml = new StringBuffer();
    while ((line = in.readLine()) != null){
        xml.append(line);
catch (Exception e){ }
finally {  // close th eresource
return xml.toString()
}String xml = getXml("http://www....");
InputSource source = new InputSource(new StringReader(xml));
// use a parse to parse the xml document in the inputsource

Similar Messages

  • How to read XML data from URL

    Hi All,
    I have one requirement. I have one URL which gives me data in XML format. I need to read this file and store this data into my SAP tables.
    Can anybody suggest how read this XML file using URL?
    Thanks in advance,
    P.Shridhar.

    Use a Server java proxy generated from your inbound message interface which would make a URLConnection to the specified URL after it gets triggered by BPM. A code snippet to achieve the same could be
    URL url  = null;
    URLConnection conn = null;
    BufferedReader in = null;
    url = new URL("http://someurl.someserver.com");
    conn = url.openConnection();
    in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String line = null;
    StringBuffer xml = new StringBuffer();
    while ((line = in.readLine()) != null){
            xml.append(line);
    -- amol

  • Reading  xml data from url and insert into table

    CREATE TABLE url_tab2
    URL_NAME VARCHAR2(100),
    URL SYS.URIType
    INSERT INTO url_tab2 VALUES
    (’This is a test URL’,
    sys.UriFactory.getUri(’http://www.domain.com/test.xml’)
    it is giving error as invalid character

    Check if your single quotes are the correct single quotes.
    The principle works as advertised in the XMLDB Developers Guide...
    C:\>sqlplus / as sysdba
    SQL*Plus: Release 11.1.0.7.0 - Production on Tue Nov 25 21:44:46 2008
    Copyright (c) 1982, 2008, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> create user OTN identified by OTN account unlock;
    User created.
    SQL> grant dba, xdbadmin to OTN;
    Grant succeeded.
    SQL> conn OTN/OTN
    Connected.
    SQL> CREATE TABLE uri_tab (docUrl SYS.URIType, docName VARCHAR2(200));
    Table created.
    SQL> -- Method SYS.URIFACTORY.getURI() with absolute URIs
    SQL> -- Insert an HTTPUri with absolute URL into SYS.URIType using URIFACTORY.
    SQL> -- The target is Oracle home page.
    SQL> INSERT INTO uri_tab VALUES
      2  (SYS.URIFACTORY.getURI('http://www.oracle.com'), 'AbsURL');
    1 row created.
    SQL> -- Insert an HTTPUri with relative URL using constructor SYS.HTTPURIType.
    SQL> -- Note the absence of prefix http://. The target is the same.
    SQL> INSERT INTO uri_tab VALUES (SYS.HTTPURIType('www.oracle.com'), 'RelURL');
    1 row created.
    SQL> -- Insert a DBUri that targets employee data from database table hr.employees.
    SQL>
    SQL> INSERT INTO uri_tab VALUES
      2  (SYS.URIFACTORY.getURI('/oradb/HR/EMPLOYEES/ROW[EMPLOYEE_ID=200]'), 'Emp200');
    1 row created.
    SQL> SELECT e.docUrl.getCLOB(), docName FROM uri_tab e;
    E.DOCURL.GETCLOB()
    DOCNAME
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN
    ">
    <html>
    <head>
    AbsURL
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN
    ">
    <html>
    E.DOCURL.GETCLOB()
    DOCNAME
    <head>
    RelURL
    <?xml version="1.0"?>
    <ROW>
      <EMPLOYEE_ID>200</EMPLOYEE_ID>
      <FIRST_NAME>Jenn
    Emp200
    SQL> set long 1000
    SQL> select HTTPURITYPE('www.oracle.com').getCLob() from dual;
    HTTPURITYPE('WWW.ORACLE.COM').GETCLOB()
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN
    ">
    <html>
    <head>
    <title>Oracle 11g, Siebel, PeopleSoft |
    Oracle, The World's Largest Enterprise S
    oftware Company</title>
    <meta name="title" content="Enterprise Applications | D
    atabase | Fusion Middleware | Applicatio
    ns Unlimited | Business | Oracle, The Wo
    rld's Largest Enterprise Software CompanEdited by: Marco Gralike on Nov 25, 2008 10:13 PM

  • Reading XML Data from ABAP Program?

    Hi,
    How do I read XML Data from an ABAP Program? For example if I have the below basic XML Code-
    <xml>
    <Name> Thiru </Name>
    <Age> 24 </Age>
    <City> chennai </Chennai>
    </xml>
    How do i read the data within the Name,Age, and City tags into variables in the ABAP Program?
    Regards,
    Thiru

    if you decide to do in XSLT, I have a sample list here:
    XML file like this:
    <?xml version="1.0" encoding="UTF-16"?>
    <F>
    <P1>
    <t_1>value1</t_1>
    <t_2>testvalue</t_2>
    </P1>
    <P2>
    </P2>
    </F>
    XSLT file like this:
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sapxsl="http://www.sap.com/sapxsl" version="1.0">
    <xsl:strip-space elements="*"/>
    <xsl:template match="F">
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    <asx:values>
    <<b>DOCUMENT</b>>
    <xsl:apply-templates/>
    </<b>DOCUMENT</b>>
    </asx:values>
    </asx:abap>
    </xsl:template>
    <xsl:template match="P1">
    <ENTRY>
    <<b>T_1</b>><xsl:value-of select="t_1"/></T_1>
    <<b>T_2</b>><xsl:value-of select="t_2"/></T_2>
    </ENTRY>
    </xsl:template>
    </xsl:transform>
    ABAP program like this:
    DATA: BEGIN OF wa_upload,
    text(255) TYPE c,
    END OF wa_upload,
    itab_upload LIKE TABLE OF wa_upload,
    BEGIN OF wa_document,
    t_1 TYPE string,
    t_2 TYPE string,
    END OF wa_document,
    itab_document LIKE TABLE OF wa_document.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = 'XXXXX'
    filetype = 'ASC'
    TABLES
    data_tab = itab_upload.
    CALL TRANSFORMATION zrappel_xml_test
    SOURCE XML itab_upload
    RESULT <b>document</b> = itab_document.
    You should pay attention to the bold words.
    hope it will be helpful
    thanks

  • Reading XML data from .pages file

    Hi All!
    I've been trying to get a script up and running, but frankly I'm lost. The script should read the date, lesson no, and name fields from a .pages file and then use that information to send an e-mail.
    What I'm having a problem with is reading the data from the .pages file and I don't know what the best way to do it is because I'm still a novice at this.
    So there are two ways I can think of:
    1. Read directly from the Pages document when it is open. The problem with this is that it's a Pages template and it contains tables. Perhaps the easiest thing would be just to select certain cells directly from pages, but I have no idea how they're labeled or how to access them so I came up with a second idea. If you happen to know how to do this, I would greatly appreciate it.
    2. Pages documents can be unzipped and one of the files is an xml file with a lot of tags and the data I need. I found the following post that talks about how to parse XML via an XSL stylesheet. After going through some tutorials, I got stuck because the xml itself in the Pages file is just a mess to me and I'm confused about which node to choose. In other xml docs you can see a clear, nicely laid out tabbed structure so you can at least figure out the path to the node you want. I stumbled across a nice script for TextWrangler which cleans up XML, but it just barks at the Pages file.
    3. On top of that, I will need to use the name field and match that with an Address Book e-mail address. Should I change the template and make it into an address book field?
    Thanks in advance,
    Paul

    The script should read the date, lesson no, and name fields from a .pages file and then use that information to send an e-mail.
    Maybe you might want to try the following script:
    tell application "Pages"
        activate
        tell foreground layer of page 1 of front document
            select (text box 1 whose vertical position < 0.5)
            tell application "System Events"
                keystroke "c" using {command down} -- ⌘C
                keystroke "a" using {shift down, command down} -- ⇧⌘A
            end tell
            set theText to the clipboard
        end tell
    end tell
    set TID to AppleScript's text item delimiters
    set AppleScript's text item delimiters to tab
    set theTextFields to text items of theText
    set AppleScript's text item delimiters to TID
    set {theDate, theLessonNo, theStudent} to {item 2, item 4, item 6} of theTextFields

  • JAXB: Read XML data from a String?

    Hi,
    I get XML data not from file but as a string and I wanted to use JAXB to parse it and get my Java Objects.
    The unmarshall methods wants an "InputStream", but "StringBufferInputStream" is deprecated, so that I don't know a way to use my String as InputStream.
    Can someone give me a hint other then writing the data in a file first?

    Hi FrankSch,
    The unmarshall methods wants an "InputStream", but
    "StringBufferInputStream" is deprecated, so that I
    don't know a way to use my String as InputStream.
    Can someone give me a hint other then writing the data
    in a file first?Yes, the class StringBufferInputStream is deprecated, and the deprecation notice reads:
    Deprecated. This class does not properly convert characters into bytes. As of JDK 1.1, the preferred way to create a stream from a string is via the StringReader class.
    The JDK API usually mentions an alternative to the deprecated method/class and in this case, you should use java.io.StringReader. It has one constructor and should suite you nicely:
    StringReader(String s) That way, you get an InputStream object; you can now use JAXB.
    Hope this helps,
    -ike, .si

  • Read XML data from file

    Hello!
    I have data in an xml file which i want to read into my program. The problem is i do not want to parse the whole file at once, but in sequece, maybe in to or three sequences. In other words i want to parse the frist part of the file, and then the next sequence.
    Is this possible and how? I use a SAXParser right now, but it parses the whole file at once. Examles and refrences to java api is appreciated
    Best Regards
    Yoshi

    Ok!
    the problem is not to call the function several times, but that the function parse in SAXParser parses the whole xml file at once, so im not sure how a switch case loop is going to help me, maybe you could clarify a little.
    The data in the xml file contains history im going to read into the program, simulating progress. each root element contains a progress. So i want to read one element at a time everey time i call the parse function or a function containing the SAXParse function
    like this
    <datafile>
    <loggfile>
    <time>10:11</time>
    <data>12323></data>
    </loggfile>
    <loggfile>
    <time>10:12</time>
    <data>12424</data>
    </loggfile>
    </datafile>
    best regards
    Yoshi

  • How to read xml data from jsf,

    Hi
    I would like to know how to read data in an xml so as we can display that data onto the jsf page to the user, say as a data table, or in an output txt box etc...

    This is nothing JSF-special. Just convert XML to objects (DTO's) and then use them in JSF.
    There are several ways to crawl the XML tree. JXPath and DOM4J are popular.

  • Read XML data from Internet Site

    Hello,
    The requirement is to read Bank Exchange Rates from the website,
    http://www.nbp.pl/Kursy/xml/a141z080721.xml
    I have tried to read it using the Function Module 'HTTP_GET'
    with the parameters:
    ABSOLUTE_URI                                    http://www.nbp.pl/Kursy/xml/a141z080721.xml
    REQUEST_ENTITY_BODY_LENGTH      1000000000
    RFC_DESTINATION                               SAPHTTP
    BLANKSTOCRLF                                   X
    TIMEOUT                                               5
    But I get the error as
    Exception       CONNECT_FAILED
    Message ID:          04                         Message number:           100
    Message:
    Connect Error: NiHostToAddr proxy error: NIEHOST_UNKNOWN
    Please let me know what am I doing wrong, or if there are some configurations that need to be done. Thanks in advance.
    P.S: Deserving Answers will be given points.

    Hi,
    i make it in this way:
      CALL FUNCTION 'HTTP_GET'
        EXPORTING
          ABSOLUTE_URI          = URI
          RFC_DESTINATION       = 'SAPHTTP' "s. THTTP PräsenServer
         RFC_DESTINATION       = 'SAPHTTPA' "s. THTTP AppliServer
          BLANKSTOCRLF          = 'Y'
    in URI is the webaddress.
    It works OK.
    Is there the correct entry in table THTTP?
    Regards, Dieter

  • Read/write xml data from/to adobe livecycle forms (pdf)

    Hello,
    I need some help reading xml data from pdfs created by Adobe LiveCycle and also writing xml data back to the form.
    The forms have been created using PROD LC 8.2 and in the future they will be created using PROD LC 9.5.
    I am using Visual Basic .NET to access the data programatically.
    Can anyone help me with some hints? A library, SDK? Any information would be very helpful.
    I am quite new with this Electronic Forms issue and I do not even know where to start.
    Thank you,
    Ionel

    Hi lonel,
    Do you want an online solution?
    I mean, it follows this workflow:
    1. The user will open the PDF by clicking a link, and a server-side program will generate the PDF and prepopulate it with data from some data sources, and render the PDF to the client (Browser),
    2. The user will fill the PDF.
    3. The user will click a Submit button and save the PDF and Data on the server.
    4. If the user wants to edit the Submitted Form, he will click a link to open the save PDF and possibly prepopulate some fields with data from other data sources, and complete the cycle of filling and saved the PDF and Data on the server.
    5. While the user is filling the PDF (inside a Browser), there might be a need to perform some lookup on the server, and update the form parts accordingly as a result of the lookup process.
    For 1-4 above, I have developed a complete base library using ASP.NET which helps you to perform the above.
    You can goto my Google Workspace and you will find a bunch of documents, sample PDFs, collections and VB Classes. To best view them, login using some Google Account.
    For point 4 above, one way to perform this effect, is to regenerate the required XML Data (which has the saved data before and the new lookup data), remerge the entire XML result with and empty PDF Form, and render the XFA (PDF Form) back to the client. But, if the PDF has one or more signatures, it will not work. So, in this case, you can update the Form Fields of a Saved PDF Form with new Data from the server, but the net effect is that you will have to loose all the signatures that were added on the PDF before.
    For 5 (above) there are 3 methods:
    1. Using a Web Service as a Data Connection. This is very easy if you have a traditional Web Service. I have used this method several times and will use it again if the need be. But, there is a problem. If the result of the Web Service is an Array of some Data, and you want to remerge the XFA to get the required effect after executing the web service ... and ... if there are some Drop-Down-List (DDL) fields, the bindings of the DDL Items of those fields will be lost. But, you can rebuild them (on enter event of the DDL Field)  if you have saved them in the embedded XML Data.
    2. You can update few (not many) fields while the PDF is opened (under the Browser via IFRAME) by passing the new field values using the URL Query String method. I have not done this, but I like this method, and I think it is cool. You need to write a server side code to ensure the the new filed values are passed back to the client using the correct URL with the Query String, and you need to write some javascript code inside the PDF to parse the URL and get the new field values and update them accordingly. See this as an example:
    http://www.halnesbitt.com/pages/pdfqs.php
    3. This method is very advanced and uses message communication ques between the Browser and the PDF (which is opened inside IFRAME element) using HostContainer object. This method will enable 2-way communication between the Browser and the PDF on the client side using javascript. I'd love to use this method one day. See example here:
    http://www.windjack.com/WindJack/Browser2PDF/brwsr2acroJS.htm
    I hope this will be of help to you.
    Tarek.

  • I'm trying to read some XML data from temperature logger over my network. I'm using LabView version 2009 sp1. I'm using the URL Get Document Vi. It works fine when using Internet sites like google or foxnews etc...

    I'm trying to read some XML data from temperature logger over my network.  I'm using LabView version 2009 sp1.  I'm using the URL Get Document Vi.  It works fine when using Internet sites like google or foxnews etc...
    When I use it with my temperature logger most of the time I get an Error 66...but some times it does work and actually retrieves the document. 
    I can use the same address "http://172.22.21.68/XMLfeed.rb" (Internet Explorer or Google Chrome) in my browser and get a response every time.  When accessing from my browser the server in the temperature logger does take around 6 seconds to respond, but it does respond every time. 
    Is the URL Get Document Vi exceeding a timeout?  If so, where can I set it to wait longer?
    Attachments:
    Error 66.jpg ‏183 KB

    It looks like the TCP Buffered Read has a 2.5 sec timeout, I believe that is where I had trouble as well.  Try creating your own URL Get HTTP Doc vi in which you call URL Get Document in normal mode, with an appropriate number of characters to fetch (enough characters so that you capture all the important data in the XML file).
    Attachments:
    ex1.PNG ‏33 KB

  • Can not read data from URL!

    Hello,
    I want to read data from URL (http://84.100.130.82:8000/;stream.nsv). But can not do it. Because when try to call function openDataInputStream() shows this error: java.io.IOException: response does not start with HTTP it starts with: ICY. How I can fix this bug?
    HttpConnection c = null;
    InputStream is = null;
    OutputStream os = null;
    StringBuffer b = new StringBuffer();
    String           response,
    responseLitle;
    c = (HttpConnection)Connector.open(&#8220;http://84.100.130.82:8000/;stream.nsv&#8221;);
    os = c.openOutputStream();
    os.flush();
    is = c.openDataInputStream();     // ERROR CODE HERE
    int ch;
    // receive output
    while ((ch = is.read()) != -1)
    b.append((char) ch);
    response = b.toString();Regards, Ramunas

    Hi, I�m trying to do the same as above, get MP3 from a Shoutcast server.
    I got the same fault ("response does not start with HTTP it starts with: ICY") when I tried to open an HttpConnection as bellow:
    ============================================
    HttpConnection conn = (HttpConnection) Connector.open("http://64.236.34.196/stream/1074");
    Then I tried to open a socket connection as bellow:
    ======================================
    SocketConnection conn = (SocketConnection) Connector.open("socket://64.236.34.196:80");
    String get = "GET /stream/1074 HTTP/1.1";
    DataOutputStream os = conn.openDataOutputStream();
    os.writeUTF(get);
    InputStream is = conn.openInputStream();
    But then I got the following error:
    =========================
    java.lang.SecurityException: Target port denied to untrusted applications
    Could someone help me to find out what is going on?
    Thanks a lot!

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • Reading JSON data from a URL

    Hi all,
    I have a requirement of reading JSON data from a particular URL and using one of the value to set one property in iView. I need some info on how to get JSON data from a URL and extracting attribute's value from it.
    What are the APIs that can be used for this?Can anyone provide a solution/working example in Java for this?
    I am working on EP 7.3.

    Hi Tarun,
    JAXB should work for you. Take a look at this example:
    JAXB JSON Example | Examples Java Code Geeks
    Regards,
    Tobias

  • Reading the data from XML Source

    Hi
    i want to read the data from XML source file, and update the transaction information to another XML file. how we can do this in ADF, please help
    Thanks
    nidhi

    you may use normal Java API to do that
    http://www.javablogging.com/read-and-write-xml/

Maybe you are looking for

  • Additional field in SAP Infoset - internal table

    Hi Gurus, I have invoices like: VBELN    Matnr     mtart 1234           Ek21    MCFE 1234           Ek33    MCFE 1234            Ek29    MCFE 1234           321       MRM1 1235          EK11      MCFE 1235           EK17      MCFE 3212           EK23

  • Mini DisplayPort to support both audio and video coming soon?

    So I notice that Apple updated the MacBook Pro Mini DisplayPort implementation to support BOTH audio AND video. Think this will make it's way to the Mac mini soon, or an update still a long way off?

  • Getting images stored inside aknown folder..

    Hello, I have aprogram that generate apictures and save them at known path.say " C:/images", then each image is assignes a random number in an accending way. Now i want away to get the name of the images inside the folder at the path " C:/images" by

  • HT4913 My iPad says I don't have IOS so I'm unable to down load things...help

    How do I down load IOS or a more up to date iOS

  • Extracting data from XML

    Im fairly new to XML & web services so bear with me please. Im trying to extract data from XML documents where the structure/element names are unknown. The condition for extracting data is if keyword matches some data content. Im using Java and the D