-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] how to get values from XML File (XML File in Browser) #2288
Comments
Hey @osmenia, Using const playwright = require('playwright');
(async () => {
const browser = await playwright.chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
// I saved your XML file to `a.xml`.
await page.goto('file://' + __dirname + '/a.xml');
// Query all `food` tags on the page, and run the function in the page context.
console.log(await page.$$eval("food", foods => foods.map(food => ({
name: food.querySelector('name').textContent,
price: food.querySelector('price').textContent,
description: food.querySelector('description').textContent,
calories: food.querySelector('calories').textContent,
}))));
await browser.close();
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!
XML:
The text was updated successfully, but these errors were encountered: