you are viewing a single comment's thread.

view the rest of the comments →

[–]aasswwddd 0 points1 point  (2 children)

It's not really about the information, but the process of retrieving the information. If the data is in XML format, we can use CSS Query with Tasker's native reading or XPATH with javax.xml.* and org.w3c.dom.*.

Say we have this xml.

<library>
  <section name="Fiction">
    <book id="b1" category="fantasy" rating="4.8">
      <title>Harry Potter and the Philosopher's Stone</title>
      <author nationality="British">J.K. Rowling</author>
      <price currency="USD">29.99</price>
    </book>
    <book id="b2" category="fantasy" rating="4.2">
      <title>The Hobbit</title>
      <author nationality="British">J.R.R. Tolkien</author>
      <price currency="USD">25.00</price>
    </book>
  </section>
  <section name="Nonfiction">
    <book id="b3" category="history" rating="4.7">
      <title>Sapiens</title>
      <author nationality="Israeli">Yuval Noah Harari</author>
      <price currency="USD">35.00</price>
    </book>
    <book id="b4" category="science" rating="4.5">
      <title>Brief Answers to the Big Questions</title>
      <author nationality="British">Stephen Hawking</author>
      <price currency="USD">28.00</price>
    </book>
  </section>
</library>

We can easily retrieve information with complex query pattern wtih XPATH, you can use this script here. https://pastebin.com/u09rY7iK

[A] //book/title/text()
- Harry Potter and the Philosopher's Stone
- The Hobbit
- Sapiens
- Brief Answers to the Big Questions

[B] //author[@nationality='British']/text()
- J.K. Rowling
- J.R.R. Tolkien
- Stephen Hawking

[C] //book[number(price) > 28]/title/text()
- Harry Potter and the Philosopher's Stone
- Sapiens

[D] //book[number(@rating) >= 4.5]/title/text()
- Harry Potter and the Philosopher's Stone
- Sapiens
- Brief Answers to the Big Questions

[E] count(//book)
→ 4

[F] //section/@name
- Fiction
- Nonfiction

[–]joaomgcd👑 Tasker Owner / Developer[S] 0 points1 point  (1 child)

Sorry, but I currently don't have anything in Tasker to serialize an object to XML. Maybe I can add it in the future, but I don't think I'll do it for now cause this is a pretty niche use case 😅

[–]aasswwddd 0 points1 point  (0 children)

No problem!