Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
I tried using a DOM parser in Thingworx, but the result is DOM parser not defined, Is there any extension or any way I can use XML parser so that I can be able to perform the XML modifications without converting it every time for any modification.
Hi Lipsa, I don't think there's any extension available on DOM, however have you checked the Universal Convertor though not sure if this is exactly what you are looking for as it converts the XML documents to Infotable
BTW for your DOM parser error I looked around not sure if you have already seen this but you'll need to define the MIME type
var string = '<!DOCTYPE html><html><head></head><body>content</body></html>';
var doc = new DOMParser().parseFromString(string, 'text/html');
doc.body.innerHTML; // or doc.querySelector('body').innerHTML
See this for more detail
Thanks, I tried this but DOM parser is not working in Thingworx
Hello Lipsa Das,
What did you tried already and with what result? If you need more advanced functions, you can always create a custom extension - in Java it is usually easier to handle more complex tasks.
Regards,
J.
I tried using Universal converter, but it converts XML to infotable, then again from converting infotable to xml I am facing problem, If I could use DOM parser or any other XML parser then I could directly modify the changes that I have to do in XML file without converting it.
Hi Lipsa Das,
What kind of error you got? You try to do the conversion in the ThingWorx service? Please note, that in the services we can only use vanilla JavaScript.
Personally, I would create a ThingWorx extension and do any necessary parsing / conversion using the available Java libraries there. Do you need more information on how to create extension?
Regards,
J.
Hello Jakub Kaczynski,
Thanks for your suggestion, as I am a fresher to Thingworx, I would really be glad to know about Thingworx extension.
Regards,
Lipsa
If you are starting afresh you probably want to see the details here at the ThingWorx Marketplace and search for the ThingWorx Extension SDK additionally to get you started easily there is an Eclipse plugin available for ThingWorx Extension SDK
Hello Lipsa Das,
As Sushant mentioned, you have a few resources to check:
In the link above you can find two important artifacts:
1. ThingWorx Extension Eclipse Plugin - a plugin to Eclipse to make your extension development a little bit faster and easier.
2. Extension SDK - a set of libraries that are necessary to use ThingWorx API.
And here you have Extension Developer Guide:
https://marketplace.thingworx.com/search?q=extension%20sdk
If you will have any question, do not hesitate to ask.
Regards,
J.
One second, if you want to manipulate XML object from Server Side Javascript you have support Out Of the Box.
Server Side Javascript it's executed by Rhino JavaScript engine which implements ECMAScript for XML (E4X).
Best Regards,
Carles.
Hi Carles,
No one denies this possibility, I just mentioned, that this is (relatively) easier, if you use Java with some useful libraries.
Regards,
J.