Tuesday, March 20, 2012

Processing XML with defined namespaces

I'm trying use the SSIS XML Task to process some XML files that have namespaces and schemas defined . One of the things I am doing is trying to perform an XPATH query on the files. However, I'm unable to provide either a namespace manager or XsltContext to the XML Task and that causes the XML Task to not understand my XPATH queries.

For example, if my XML is:

<o:object id="12345" xmlns:o="urn:some-urn"/>

and my desired XPATH is "/o:object/@.id", I get the following error:

Error: 0xC002F304 at Query, XML Task: An error occurred with the following error message: "Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.".

Of course, the XPATH "/object/@.id" returns nothing as expected.

Is there a way around this?

I'm having the same problem with .NET "System.Xml" have you found a solution to this?|||

I'm getting the same (Xml Task) error. I need my XPath to be /SOAP-ENV:Envelope/SOAP-ENV:Body.

The only way I could work around it was to write the XPath without using the namespace prefix like this:

/*[local-name() = 'Envelope']/*[local-name() = 'Body']

|||

A Barber wrote:

I'm having the same problem with .NET "System.Xml" have you found a solution to this?

what exactly is the problem that you're experiencing with system.xml?

No comments:

Post a Comment