Reading handshake into python works

This commit is contained in:
Jonas Linter
2025-09-25 09:47:38 +02:00
parent 9ea09ffa3f
commit 35da6d3c24
11 changed files with 44 additions and 15 deletions

View File

@@ -1,4 +1,5 @@
from generated.alpinebits import OtaPingRq, OtaPingRs
from ..generated.alpinebits import OtaPingRq, OtaPingRs
from xsdata_pydantic.bindings import XmlParser
@@ -6,15 +7,26 @@ from generated.alpinebits import OtaPingRq, OtaPingRs
def main():
# test parsing a ping request sample
path = "../../AlpineBits-HotelData-2024-10/files/samples/Handshake/Handshake-OTA_PingRQ.xml"
path = "AlpineBits-HotelData-2024-10/files/samples/Handshake/Handshake-OTA_PingRQ.xml"
with open(
path, "r", encoding="utf-8") as f:
xml = f.read()
# Parse the XML into the request object
request = OtaPingRq.from_xml(xml)
print("Parsed OTA_PingRQ:", request)
# Test parsing back
parser = XmlParser()
parsed_result = parser.from_string(xml, OtaPingRq)
print(parsed_result.echo_data)
if __name__ == "__main__":