Skip to content

Conversation

karan96108
Copy link

Add child node traversal methods to Element class

Problem

Currently users need to switch between requests-html and lxml.etree to work with child nodes,
creating unnecessary complexity.

Implementation

Added two methods to Element class:

  • children property - Returns list of direct child elements
  • getchildren() method - Provides lxml.etree compatibility

Breaking Changes

None. Adds new functionality while maintaining backwards compatibility.

Usage

# Using property
for child in element.children:
    print(child.tag)

# Using lxml-compatible method 
for child in element.getchildren():
    print(child.tag)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant