Skip to contents

sources() and problems() return the two companion tables the package produces alongside its tidy URL rows: the per-source fetch-metadata records and the non-fatal parse problems table. They dispatch on the object type, so the same call works on a read_sitemap() result and on a sitemap_audit() object:

Usage

sources(x, ...)

# Default S3 method
sources(x, ...)

# S3 method for class 'sitemap_audit'
sources(x, ...)

problems(x, ...)

# Default S3 method
problems(x, ...)

# S3 method for class 'sitemap_audit'
problems(x, ...)

Arguments

x

A read_sitemap() result (a tidy tibble carrying the sources/problems attributes) or a sitemap_audit() object.

...

Ignored; reserved for future methods.

Value

For sources(), the per-source fetch-metadata records; for problems(), the non-fatal parse problems table. A sitemap_audit() object always yields the documented (possibly zero-row) component; a read_sitemap() result yields its attached companion table.

Details

The default methods return the requested attribute (or NULL when the object carries none), so they are safe to call on any object.

See also

audit_sources() and audit_problems() for the sitemap_audit component accessors.

Examples

xml <- paste0(
  '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
  '<url><loc>https://example.com/</loc></url></urlset>'
)
path <- tempfile(fileext = ".xml")
writeLines(xml, path)
urls <- read_sitemap(path)

sources(urls)
#>                         requested_url                           final_url
#> 1 /tmp/Rtmpd4DRti/file78a472a4ec4.xml /tmp/Rtmpd4DRti/file78a472a4ec4.xml
#>   status redirect_chain content_type charset bytes timing error_class
#> 1     NA                        <NA>    <NA>   112     NA        <NA>
#>       format root namespaces profile_id
#> 1 xml-urlset <NA>                  <NA>
problems(urls)
#> # A tibble: 0 × 4
#> # ℹ 4 variables: severity <chr>, category <chr>, subject_ref <chr>,
#> #   message <chr>

# The same accessors work on a sitemap_audit object.
audit <- sitemap_audit(urls = urls)
sources(audit)
#>                         requested_url                           final_url
#> 1 /tmp/Rtmpd4DRti/file78a472a4ec4.xml /tmp/Rtmpd4DRti/file78a472a4ec4.xml
#>   status redirect_chain content_type charset bytes timing error_class
#> 1     NA                        <NA>    <NA>   112     NA        <NA>
#>       format root namespaces profile_id
#> 1 xml-urlset <NA>                  <NA>
problems(audit)
#> # A tibble: 0 × 4
#> # ℹ 4 variables: severity <chr>, category <chr>, subject_ref <chr>,
#> #   message <chr>