XML Parse Action

LinerSeven

Active member
Hi,

Could you implement an action to parse XML in Macrodroid?

I'm aware XML is an old standard,
but the "Hot Pepper" Japan API returns results in XML.

I tried ParseTask (Tasker Plugin),
but it did not work well....

Best Regards,

Liner Seven
 

sampleuserhere

Active member
XML is still pretty relevant though, we could use the reading capability to read HTML too since they are pretty much similar. Such action will be useful for web-scrapping!

Do you mind sharing a sample API? Maybe some people here could spin it with ParseTask.
 

sampleuserhere

Active member

Quidn

Passionate Member
I tried ParseTask (Tasker Plugin),
but it did not work well....
Actually I too thought parse XML action would be useful and also experienced that the ParseTask doesn't work as expected.

But for now, there are some alternatives to parse XML or convert XML to JSON.
 

LinerSeven

Active member
Hi, @sampleuserhere,

Return value is Null in my environment....

If the seed value is changed from %XML to XML, it will not work.

Best Regards,

Liner Seven
 

Attachments

  • Screenshot_20231014-040914.png.jpg
    Screenshot_20231014-040914.png.jpg
    38.8 KB · Views: 11
  • Screenshot_20231014-040924.png.jpg
    Screenshot_20231014-040924.png.jpg
    20.1 KB · Views: 11
  • Screenshot_20231014-040932.png.jpg
    Screenshot_20231014-040932.png.jpg
    18.4 KB · Views: 11

LinerSeven

Active member
Hi, @Quidn,

Thanks for your suggestions.
+1 Buldak Myong :p

You mean using HTTP Shortcut advanced script?

If the variable is "XML",
ParseXML (XML)?

Could you provide me with a sample capture image?

Best Regards,

Liner Seven
 

Quidn

Passionate Member
Could you provide me with a sample capture image?
Here you are:
Q231014ParseXML.png
Screenshot_20231014_045457_MacroDroid.png
Screenshot_20231014_045646_HTTP Shortcuts.png
Screenshot_20231014_045718_HTTP Shortcuts.png
Screenshot_20231014_045740_HTTP Shortcuts.png




Result:​

Screenshot_20231014_045544_MacroDroid.png
Screenshot_20231014_045604_MacroDroid.png

Additionally, if the URL has to be changed dynamically, you can set variables by MacroDroid before requesting, or it can be handled within HTTP Shortcuts for some cases. There would be several different approaches to change variables dynamically, which depend on cases.
 

LinerSeven

Active member
Hi(An-Nyong), @Quidn,

Thank you.
I've solved my problem.

This is great!

It was a new discovery to be able to put a plugin in between the way XML is converted to JSON using the "parseXML" function in the Java Script.

If I've a variable with the same name as Macrodroid on the HTTP Shortcut side and incorporate it into the HTTP Shortcut request URL, it is more versatile than using ParseTask.

Best Regards,

Liner Seven
 

Attachments

  • Screenshot_20231014_113304.png.jpg
    Screenshot_20231014_113304.png.jpg
    38 KB · Views: 9
  • Screenshot_20231014-113352.png.jpg
    Screenshot_20231014-113352.png.jpg
    32.8 KB · Views: 8
  • Screenshot_20231014-113420.png.jpg
    Screenshot_20231014-113420.png.jpg
    11 KB · Views: 6
  • Screenshot_20231014-113430.png.jpg
    Screenshot_20231014-113430.png.jpg
    46 KB · Views: 8

Quidn

Passionate Member
I'm so glad to hear you've solved the problem.

If I've a variable with the same name as Macrodroid on the HTTP Shortcut side and incorporate it into the HTTP Shortcut request URL, it is more versatile than using ParseTask.
Actually I didn't know that variables could be exchanged, because it was a known-issue🔗 until just a month and a half ago. That's why I didn't mentioned that feature.
I think your discovery is more valuable than my tips. Perhaps this is why it would be good to we share information, and it becomes add more value!

I didn't really use HTTP Shortcuts and all were just test purpose like this due to the limitation:
Screenshot_20231014_120401_HTTP Shortcuts.png

But now it seems that we can use it as a handy JavaScript interpreter for broad purposes.
I thank you as well. 😃

using the "parseXML" function in the Java Script.
Just one thing for your information, parseXML() function is not a native function from JavaScript. It's a custom function implemented within the HTTP Shortcuts. That's why I mentioned like this:
Using HTTP Shortcuts as plugin - It has built-in parseXML() function and could return to MacroDroid as JSON string
 
Top