XPATH JSONPATH XML e Xtended Markup Language XML

  • Slides: 11
Download presentation
XPATH & JSONPATH

XPATH & JSONPATH

XML (e. Xtended Markup Language) • XML õppetund w 3 Schools lehel – http:

XML (e. Xtended Markup Language) • XML õppetund w 3 Schools lehel – http: //www. w 3 schools. com/xml/default. asp • Root element (document element) • <element_name attribute_name="attribute_value"> Element Content </element_name> • Element content võib olla Child element • XML’i näited http: //www. w 3 schools. com/xml/cd_catalog. xml http: //www. w 3 schools. com/xsl/books. xml

XML namespaces <root xmlns: h="http: //www. w 3. org/TR/html 4/" xmlns: f="http: //www. w

XML namespaces <root xmlns: h="http: //www. w 3. org/TR/html 4/" xmlns: f="http: //www. w 3 schools. com/furniture"> <h: table> <h: tr> <h: td>Apples</h: td> <h: td>Bananas</h: td> </h: tr> </h: table> <f: name>African Coffee Table</f: name> <f: width>80</f: width> <f: length>120</f: length> </f: table> </root> • http: //www. w 3 schools. com/xml_namespaces. asp

XPATH • XPATH õppetund w 3 Schools lehel iseseisvaks lugemiseks tunnis: – http: //www.

XPATH • XPATH õppetund w 3 Schools lehel iseseisvaks lugemiseks tunnis: – http: //www. w 3 schools. com/xml_xpath. asp • XPATH on päringukeel XML dokumentidest informatsiooni otsimisest nagu SQL on päringukeel andmebaasi tabelitest otsimiseks.

XPATH’i näited • Online vahend – http: //codebeautify. org/Xpath-Tester • Näite XML – http:

XPATH’i näited • Online vahend – http: //codebeautify. org/Xpath-Tester • Näite XML – http: //www. w 3 schools. com/xml/cd_catalog. xml • Pärime välja kõik title’d – /CATALOG/CD/TITLE – //TITLE • Pärime välja kõik cd’d, mille hind on suurem kui 10 – /CATALOG/CD[PRICE>10]

Ülesanne 1 (xpath) • Kirjuta XPATH-ga päring, mis tagastaks kõik raamatu (book) pealkirjad (title),

Ülesanne 1 (xpath) • Kirjuta XPATH-ga päring, mis tagastaks kõik raamatu (book) pealkirjad (title), mille kategooriaks (category) on märgitud WEB ja hind (price) on suurem kui 40. – http: //www. w 3 schools. com/xml/books. xml • 0. 5 punkti

JSON (Java. Script Object Notation) • Nimi-väärtus paaride kollektsioon {„nimi“: “Juhan“ , „vanus“: 21

JSON (Java. Script Object Notation) • Nimi-väärtus paaride kollektsioon {„nimi“: “Juhan“ , „vanus“: 21 } • http: //www. w 3 schools. com/json/

JSONPath • Xpathi analoog JSON-i jaoks • http: //goessner. net/articles/Json. Path/ • Online vahend

JSONPath • Xpathi analoog JSON-i jaoks • http: //goessner. net/articles/Json. Path/ • Online vahend – http: //jsonpath. com/

Ülesanne 2 (jsonpath) • Konverteerige ülesandes 1 antud xml -> json formaati • Sooritage

Ülesanne 2 (jsonpath) • Konverteerige ülesandes 1 antud xml -> json formaati • Sooritage ülesandes 1 kirjeldatud päring kasutades jsonpath-i. • 0. 5 punkti

Ülesanne 3 (xpath) • Leia järgmisest uudistevoo xml-st: – http: //www. aripaev. ee/mod/rss. xml

Ülesanne 3 (xpath) • Leia järgmisest uudistevoo xml-st: – http: //www. aripaev. ee/mod/rss. xml • Kõikide uudiste (item) lingid (link), kus kirjeldused (description) sisaldavad sõna ‘Eesti’. • 0. 5 punkti

Lisaülesanne (xpath) • Leia Postimehe kodulehelt www. postimees. ee postimehe logo element (<a class="pm.

Lisaülesanne (xpath) • Leia Postimehe kodulehelt www. postimees. ee postimehe logo element (<a class="pm. Logo„ href="http: //www. postimees. ee"></a> või <a href="http: //www. postimees. ee/v 2" class="header__logo"></a>) kasutades x. Pathi saad proovida kasutades fire. Bugi või Chrome'i konsooli (F 12) • 0. 5 punkti