1

I have XML in this example format:

<ExternalEvent xmlns="http://www.redeyedmonster.co.uk/Integration/ESB">
    <EventType>Create</EventType>
    <Message>SomeMessage</Message>
    <ServiceRequestId>75a144b8-5a11-e311-bd23-0050569f00cc</ServiceRequestId>
    <SourceSystem>MySource</SourceSystem>
</ExternalEvent>

and I am stuck with it.

I am trying to evaluate the value of the EventType node. I have tried:

/ExternalEvent/EventType

and

/*[local-name() = 'ExternalPath' and *[local-name() = 'EventType']]

and

/*[local-name()='ExternalEvent' and namespace-uri()='http://www.redeyedmonster.co.uk/Integration/ESB']/*[local-name()='EventType' and namespace-uri()='http://www.redeyedmonster.co.uk/Integration/ESB']

plus many other variations. However in XPath Tester I always get the same error which is:

The default (no prefix) Namespace URI for XPath queries is always '' and it cannot be redefined to 'http://www.redeyedmonster.co.uk/Integration/ESB'.

If I remove the namespace phrase (xmlns="http://www.redeyedmonster.co.uk/Integration/ESB") from the XML then I am able to evaluate the value of event type no problem but unfortunately I am stuck with XML in this format and it cannot be changed for my solution.

Is there a way round this? As I believe it may be the the underlying cause of a routing problem I have in my ESB solution.

4

1 回答 1

1

您是否尝试过使用表达式直接获取EventType数据来获取节点,[//*local-name()='EventType']或者您甚至可以尝试[/*localname()='ExternalPath'/*local-name()='EventType']不使用 and 之类的方法。

于 2013-08-30T11:29:49.083 回答