python-zeep icon indicating copy to clipboard operation
python-zeep copied to clipboard

Improve schema-aware parsing for <xsd:any> to return structured dicts

Open kaburagisec opened this issue 4 months ago • 0 comments

Summary

This PR enhances the Any.parse_xmlelements() method to improve the deserialization of <xsd:any> elements by using schema-based type resolution where available. When child elements are found, the method attempts to:

  • Look up each child element using the provided schema
  • Deserialize them into nested Python dictionaries keyed by tag name
  • Fall back to text content or the raw lxml Element if schema resolution fails

What Changed

  • Rewrote zeep.xsd.elements.Any.parse_xmlelements() to return structured dict instead of list of raw elements
  • Supports nested parsing of child elements
  • Improved docstring to match behavior

Why

Helps improve parsing of <xsd:any> blocks in extensible XML schemas. Common in many real-world SOAP APIs.

Backward Compatibility

  • Compatible with current Zeep API
  • Falls back safely if schema lookup fails

Related Issues

  • Fixes #918
  • Fixes #582
  • Fixes #1472

Let me know if you want me to add tests or make this opt-in via setting.

kaburagisec avatar Sep 26 '25 19:09 kaburagisec