net.i2p.router.news

## Class NewsXMLParser

- java.lang.Object
- - net.i2p.router.news.NewsXMLParser

-     public class NewsXMLParser
      extends Object

  Parser for I2P news feeds in Atom format with security filtering.

  Processes news.xml files following RFC4287 Atom specification using the UPnP XML parser library with enhanced security features. Handles news entries, metadata, CRL entries, and blocklist data with configurable XHTML filtering.

  Provides comprehensive validation and sanitization of news content with support for multiple content types and security levels. Includes configurable handling of potentially dangerous XHTML elements and attributes.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `NewsXMLParser.XHTMLMode` The action taken when encountering a non-whitelisted XHTML element or blacklisted attribute in the feed content.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NewsXMLParser(I2PAppContext ctx)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `BlocklistEntries` | `getBlocklistEntries()` The blocklist entries.
    `List<CRLEntry>` | `getCRLEntries()` The news CRL entries.
    `List<NewsEntry>` | `getEntries()` The news entries.
    `NewsMetadata` | `getMetadata()` The news metatdata.
    `static List<Node>` | `getNodes(Node node, String name)` Helper to get all Nodes matching the name
    `static void` | `main(String[] args)`
    `Node` | `parse(File file)` Process the XML file.
    `Node` | `parse(InputStream in)` Process the XML input stream.
    `void` | `setXHTMLMode(NewsXMLParser.XHTMLMode mode)` Sets the action taken when encountering a non-whitelisted XHTML element in the feed content.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### NewsXMLParser

          public NewsXMLParser(I2PAppContext ctx)

  - ### Method Detail

    - #### getBlocklistEntries

          public BlocklistEntries getBlocklistEntries()

      The blocklist entries. Must call parse() first.
      Returns:
        null if none

    - #### getCRLEntries

          public List<CRLEntry> getCRLEntries()

      The news CRL entries. Must call parse() first.
      Returns:
        unsorted, null if none

    - #### getEntries

          public List<NewsEntry> getEntries()

      The news entries. Must call parse() first.
      Returns:
        sorted, newest first, null if parse failed

    - #### getMetadata

          public NewsMetadata getMetadata()

      The news metatdata. Must call parse() first.
      Returns:
        null if parse failed

    - #### getNodes

          public static List<Node> getNodes(Node node,
                                            String name)

      Helper to get all Nodes matching the name
      Returns:
        non-null

    - #### main

          public static void main(String[] args)

    - #### parse

          public Node parse(File file)
                     throws IOException

      Process the XML file.
      Parameters:
        `file` - XML content only. Any su3 or gunzip handling must have already happened.
      Returns:
        the root node
      Throws:
        `IOException` - on any parse error

    - #### parse

          public Node parse(InputStream in)
                     throws IOException

      Process the XML input stream.
      Parameters:
        `in` - XML content only. Any su3 or gunzip handling must have already happened.
      Returns:
        the root node
      Throws:
        `IOException` - on any parse error

    - #### setXHTMLMode

          public void setXHTMLMode(NewsXMLParser.XHTMLMode mode)

      Sets the action taken when encountering a non-whitelisted XHTML element in the feed content. Must be set before parse(). Default REMOVE_ELEMENT.