Skip to content

How to match xml elements with namespace ? #91

@yambati-tillster

Description

@yambati-tillster
<request xmlns:ns2="http://schemas.datacontract.org/2004/07/System">
    <Options>
        <CalculateItemPrice>true</CalculateItemPrice>
    </Options>
    <Order>
        <DestinationId>1</DestinationId>
        <Discounts/>
        <FutureOrder>
            <EmailAddress>testEmail@test.com</EmailAddress>
            <PhoneNumber>000(000)-0101</PhoneNumber>
            <PickupTime>
                <ns2:DateTime>2021-11-15T01:00:00-07:00</ns2:DateTime>
                <ns2:OffsetMinutes>0</ns2:OffsetMinutes>
            </PickupTime>
        </FutureOrder>
        <Items>
            <NewOrderItem>
                <Id>1</Id>
                <ItemId>649475714</ItemId>
                <Modifiers/>
                <Price>6.29</Price>
                <DestinationId>1</DestinationId>
            </NewOrderItem>
        </Items>
        <Name>Single Item</Name>
        <Payments>
            <NewOrderPayment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"NewExternalPayment">
                <Amount>6.80</Amount>
                <Id>2</Id>
                <TenderId>649481142</TenderId>
                <TipAmount>0</TipAmount>
            </NewOrderPayment>
        </Payments>
        <Surcharges/>
    </Order>
</request>

"matchingRules": { "body": { "$.request.Order.FutureOrder.PickupTime.{http://schemas.datacontract.org/2004/07/System}DateTime['#text']":{ "matchers": [ { "match": "regex", regex": "\\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2]\\d|3[0-1])T(?:[0-1]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+|)(?:Z|(?:\\+|\\-)(?:\\d{2}):?(?:\\d{2}))" } ] } } }

This rule is currently not matching ,Is this the right way to specify the path in the case of elements with namespace.
"$.request.Order.FutureOrder.PickupTime.{http://schemas.datacontract.org/2004/07/System}DateTime['#text']"
could not find any examples or documentation. using pact-jvm, pactSpecification specification version: 3.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions