Attributes in XMLParser

Is it possible to access the attributes of an XML element using Scriptable’s XMLParser?

Thanks for any help,

Martin

That might actually not be properly supported right now. I’ve added a todo to look into this. It shouldn’t be too difficult to support so hopefully I can squeeze it into the next update.

1 Like

I don’t think it is supported - as I was trying it out the other day. But it is kind of important.

Just wanted to let you know that attributes are now supported in the latest beta build which was published yesterday. Take a look at didStartElement which now has a second parameter.

1 Like

Excellent! That means for my uses it’ll be fine.

Would this be able to do serialization?

Long story short I need a way to do that with a xml file to send it as a post to an API.

I have no idea what the code would be or anything but if it’s possible I am willing to learn it. Also would be using scriptable to do this via shortcuts.

To serialise form json to XML, I’ve used this library: https://github.com/soldair/node-jsontoxml

To get it working, I copied the file jsontoxml.js into scriptable, then the example in the README.md works if I change the require to importModule.

Hope this helps,

Martin