Skip to main content
1-Visitor
June 17, 2014
Question

Pull in .XML website information into an infotable

  • June 17, 2014
  • 20 replies
  • 4876 views

Hello,

I am looking to learn how to get information from a .XML website and then parsing through the data and whenever it reaches a <name> or <product_description> to take that information and write it into the infotable. I have absolutely no clue how to do this so I need a lot of help.

Thank you,

Mike

    20 replies

    1-Visitor
    June 17, 2014

    Hi Michael, what is the use case for this btw? Is this temporary information going out to the mashup or information that you wish to store for a period or permanent?
    As to how to do this, please look in the Training section and look for a Video on Services/Consuming an external web page.
    That should get you up and going.



    1-Visitor
    June 17, 2014

    It won't need to be permanent as the script will have to redownload the XML file every five minutes to check for updates so it will be purely for display in a mashup. I will watch the video and let you know if I have any questions.

    Thanks Pai!



    1-Visitor
    June 17, 2014

    Pai,

    Getting an error when running the first part of the video for my xml website (the loadxml snippet)

    Wrapped java.lang.IllegalArgumentException: Illegal character in path at
    index 0: \mespabeloitsharedProductionMonitorProdMonProduct2.xml Cause:
    Illegal character in path at index 0:
    \mespabeloitsharedProductionMonitorProdMonProduct2.xml

    the website uses \ instead of / and I am assuming that is messing up the code.

    Let me know if I am wrong.

    Thank you,

    Mike Francek



    1-Visitor
    June 17, 2014

    it seems the website is not so much a website but an XML document on our internal network. Would there be a different way I go about getting this XML information into Thingworx?



    1-Visitor
    June 18, 2014

    Thingworx can load it, if it is a proper URL or if it is in the File Repository.

    Although it should be possible to refer to the document by using something like:
    file://server01\fshare\dir1\dir2\dir3\NameofFile

    1-Visitor
    June 18, 2014

    I am not getting the following error.

    Wrapped org.apache.http.client.ClientProtocolException Cause: null

    I switched the URL to read as the following

    file://mespabeloit/shared/ProductionMonitor/ProdMonProduct2.xml



    1-Visitor
    June 18, 2014

    A standard way I approach this is to first set the return type of the service as String and use GetText vs. GetXML and test that first.

    1-Visitor
    June 18, 2014

    still getting the error. My output is set to String. Below is the code I used.


    var params = {

        headers: undefined /* JSON /,<br>    useProxy: undefined / BOOLEAN /,<br>    proxyHost: undefined / STRING /,<br>    useNTLM: undefined / BOOLEAN /,<br>    ignoreSSLErrors: undefined / BOOLEAN /,<br>    proxyPort: undefined / INTEGER /,<br>    withCookies: undefined / BOOLEAN /,<br>    password: undefined / STRING /,<br>    url: 'file://mespabeloit\shared\ProductionMonitor\ProdMonProduct2.xml' / STRING /,<br>    workstation: undefined / STRING /,<br>    username: undefined / STRING /,<br>    proxyScheme: undefined / STRING /,<br>    domain: undefined / STRING /,<br>    timeout: undefined / NUMBER */
    };

    // result: STRING
    var result = Resources["ContentLoaderFunctions"].GetText(params);