Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canadapost tracking info XML not properly parsed #743

Open
MrNaif2018 opened this issue Dec 26, 2024 · 0 comments
Open

Canadapost tracking info XML not properly parsed #743

MrNaif2018 opened this issue Dec 26, 2024 · 0 comments

Comments

@MrNaif2018
Copy link

Hi! I tried to do tracking on a number LB469941154US
Like so:

request = karrio.Tracking.fetch(TrackingRequest(tracking_numbers=["LB469941154US"]))

tracking_details_list, messages = request.from_(canadapost_gateway).parse()

It returns empty array for both

But this code does exist and is trackable. When checking, proper XML is returned by canadapost api, but then the lib doesn't parse it well
Here's some part of what it returns:
Deserializable(value=['<?xml version="1.0" encoding="UTF-8"?>\n<tracking-detail xmlns="http://www.canadapost.ca/ws/track-v2"><pin>LB469941154US</pin><active-exists>1</active-exists><archive-exists/><changed-expected-date>2024-09-09</changed-expected-date><destination-postal-id>L4P0K2</destination-postal-id>

Then code does this:
details = lib.find_element("tracking-detail", response)
And it fails
Digging deeper:

nodes = [*in_element.xpath(".//*[local-name() = $name]", name=tag)]

this returns nothing
but if I remove the dot, it works this way:
nodes = [*in_element.xpath(f"//*[local-name() = '{tag}']")]

And it returns full TrackingDetails

I am not sure if it's proper fix, wanted to consult with you as I don't know what dot means in xpath parsing

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

No branches or pull requests

1 participant