-
Notifications
You must be signed in to change notification settings - Fork 5k
Closed
Description
Hi Team,
I would like to ask, how to loop through tag Food, and get the values inside the tag food (name, price,description, calories)
thanks a lot!
const { chromium } = require("playwright");
(async () => {
const browser = await chromium.launch({
headless: false,
defaultViewport: { width: 1920, height: 1080 },
slowMo: 30,
});
const crContext = await browser.newContext();
const page = await crContext.newPage();
await page.goto("C:\\playwright"); //Open Folder
await page.click("#tbody > tr:nth-child(10) > td:nth-child(1) > a"); // Click on XML File
const handles = await page.$$("div.expanded"); // through tag Food
//how to get values inside tag Food
console.log(handles); // getting [] output
//await page.close();
//await browser.close();
})();
XML:
<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>Two of our famous Belgian Waffles with plenty of real maple syrup</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>Light Belgian waffles covered with strawberries and whipped cream</description>
<calories>900</calories>
</food>
<food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>Light Belgian waffles covered with an assortment of fresh berries and whipped cream</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description>Thick slices made from our homemade sourdough bread</description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>Two eggs, bacon or sausage, toast, and our ever-popular hash browns</description>
<calories>950</calories>
</food>
</breakfast_menu>
Metadata
Metadata
Assignees
Labels
No labels