Giter Site home page Giter Site logo

oxffaa / gopher-parse-sitemap Goto Github PK

View Code? Open in Web Editor NEW
32.0 2.0 17.0 10 KB

A high effective golang library for parsing big-sized sitemaps and avoiding high memory usage. The sitemap parser was written on golang without external dependencies.

License: MIT License

Go 100.00%
golang go sitemap parser parse parsing-big-sitemaps sitemaps sitemap-files sitemap-xml sitemap-url

gopher-parse-sitemap's People

Contributors

oxffaa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gopher-parse-sitemap's Issues

How can I extend this package to parse and catch other attribute of sitemap?

This package is very handy and useful and its totally functional. However I think I could not find a way to extend and use this package in my app to catch an additional attribute of the sitemap without changing the code of package.

For example I have a sitemap like this :

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
    <url>
        <loc>https://example.com/123</loc>
        <xhtml:link rel="alternate" media="only screen and (max-width: 640px)" href="https://m.example.com/123" />
        <image:image>
            <image:loc>https://example.com/123.jpg</image:loc>
            <image:title>example title</image:title>
            <image:caption>example capltion</image:caption>
        </image:image>
    </url>
</urlset>

To catch image data I add a function GetImage() in Entry interface and implement it in sitemap_types.go file also a minor change in sitemapEntry struct. But as you see I changed the package source code which is tribe idea IMO.

I google a lot how to extend struct and interface and I find some approach which is named Composition
But I couldn't apply this because when I trace the code, at entryParser function new entry will create from sitemapEntry Struct and its not parametric so I couldn't tell to package to create and entry from extended struct which is create Composition approach.
So the question is How can I extend this package to parse and catch other attribute of sitemap without touching source code of package?

I'm new in go and any help and suggestion could be helpful

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.