cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Can I use DOM parser to modify XML in Thingworx?

ldas1
1-Visitor

Can I use DOM parser to modify XML in Thingworx?

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.

11 REPLIES 11
supandey
19-Tanzanite
(To:ldas1)

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

supandey
19-Tanzanite
(To:supandey)

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

ldas1
1-Visitor
(To:supandey)

Thanks, I tried this but DOM parser is not working in Thingworx

jkaczynski
12-Amethyst
(To:ldas1)

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.

jkaczynski
12-Amethyst
(To:ldas1)

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

supandey
19-Tanzanite
(To:ldas1)

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

jkaczynski
12-Amethyst
(To:ldas1)

Hello Lipsa Das​,

As Sushant mentioned, you have a few resources to check:

https://marketplace.thingworx.com/-/media/Marketplace/Download%20Item/Related%20Content/T/Thingworx%20Extension%20Develo…

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.

Announcements


Top Tags