Giter Club home page Giter Club logo

py-xml-sitemap-writer's People

Contributors

dependabot[bot] avatar macbre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

py-xml-sitemap-writer's Issues

Use lxml to generate large XML sitemap files

https://stackoverflow.com/a/36967668

from lxml import etree

fname = "streamed.xml"
with open(fname, "w") as f, etree.xmlfile(f) as xf:
    attribs = {"tag": "bagggg", "text": "att text", "published": "now"}
    with xf.element("root", attribs):
        xf.write("root text\n")
        for i in xrange(10):
            rec = etree.Element("record", id=str(i))
            rec.text = "record text data"
            xf.write(rec)

https://lxml.de/api/lxml.etree.xmlfile-class.html

<?xml version="1.0"?>
<root text="att text" tag="bagggg" published="now">root text
    <record id="0">record text data</record>
    <record id="1">record text data</record>
    <record id="2">record text data</record>
    <record id="3">record text data</record>
    <record id="4">record text data</record>
    <record id="5">record text data</record>
    <record id="6">record text data</record>
    <record id="7">record text data</record>
    <record id="8">record text data</record>
    <record id="9">record text data</record>
</root>

Sitemap example

<?xml version="1.0" encoding="UTF-8"?>
<!--Generated at Sat, 05 Sep 2020 00:52:13 +0200-->
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
 <!--5201290 items-->
 <sitemap>
  <loc>https://elecena.pl/sitemap-001-search.xml.gz</loc>
 </sitemap>
 <sitemap>
  <loc>https://elecena.pl/sitemap-002-shops.xml.gz</loc>
 </sitemap>
 <sitemap>
  <loc>https://elecena.pl/sitemap-003-pages.xml.gz</loc>
 </sitemap>
 <sitemap>
  <loc>https://elecena.pl/sitemap-004-datasheets.xml.gz</loc>
 </sitemap>
 <sitemap>
  <loc>https://elecena.pl/sitemap-005-datasheets.xml.gz</loc>
 </sitemap>
 <sitemap>
  <loc>https://elecena.pl/sitemap-006-datasheets.xml.gz</loc>
 </sitemap>
 <sitemap>
  <loc>https://elecena.pl/sitemap-007-datasheets.xml.gz</loc>
 </sitemap>
 <sitemap>
  <loc>https://elecena.pl/sitemap-008-datasheets.xml.gz</loc>
 </sitemap>
 <sitemap>
  <loc>https://elecena.pl/sitemap-009-parameters.xml.gz</loc>
 </sitemap>
 <sitemap>
  <loc>https://elecena.pl/sitemap-010-parameters.xml.gz</loc>
 </sitemap>
</sitemapindex>

And sub-sitemap:

<?xml version="1.0" encoding="UTF-8"?>
<!--Generated at Sat, 05 Sep 2020 00:34:02 +0200-->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
 <!--8 items-->
 <url>
  <loc>https://elecena.pl/</loc>
 </url>
 <url>
  <loc>https://elecena.pl/about</loc>
 </url>
 <url>
  <loc>https://elecena.pl/whats-new</loc>
 </url>
 <url>
  <loc>https://elecena.pl/about/shops</loc>
 </url>
 <url>
  <loc>https://elecena.pl/ads</loc>
 </url>
 <url>
  <loc>https://elecena.pl/bot.htm</loc>
 </url>
 <url>
  <loc>https://elecena.pl/stats</loc>
 </url>
 <url>
  <loc>https://elecena.pl/report</loc>
 </url>
</urlset>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.