from yattag import Doc doc, tag, text = Doc().tagtext() with tag('html'): with tag('head'): with tag('title'): text('My HTML Page') with tag('body'): with tag('h1'): text('Hello, World!') print(doc.getvalue())
from yattag import Doc doc, tag, text = Doc().tagtext() with tag('rss', version='2.0'): with tag('channel'): with tag('title'): text('My RSS Feed') with tag('link'): text('http://www.example.com') with tag('item'): with tag('title'): text('Article 1') with tag('description'): text('This is the first article') with tag('link'): text('http://www.example.com/article-1.html') print(doc.getvalue())In this example, we are using yattag to generate an RSS feed. We create an `rss` tag and specify the version, and then create a `channel` tag with a title and link. We then create an `item` tag for each article in the feed, with a title, description, and link. yattag is a third-party package library.