views:

100

answers:

1

Hi there,

I am consuming an xml response from a government gateway which contains a url in its root node twice (being firstly xsi:schemaLocation="http://www.govtalk.gov.uk/CM/envelope" and also xmlns="http://www.govtalk.gov.uk/CM/envelope")

XDocument will only parse this if I pull out the second one (the xmlns one) from the node.

Is there some way I can prepare XDocument to digest this repeated URL without having to manipulate the incoming xml in any way?

Thanks

Paul

A: 

The problem is not that there is a repeated URL, but that the XML you are receiving from the gateway is not using the xsi:schemaLocation attribute correctly. The attribute should contain pairs of whitespace separated URIs, where each pair gives the XML processor a hint about where to find the XML schema corresponding to a namespace. See http://www.w3.org/TR/xmlschema-0/#schemaLocation for an explanation of schemaLocation.

If you have to strip out something, make it the xsi:schemaLocation attribute.

If you are validating the received XML against a schema then you will have to take steps to provide the location of the schema document, for instance populating an XmlSchemaSet and passing it to the Validate extension method.

Adam
Thanks for the steer.Following what you said, I think the xsi:schemaLocation attribute might actually be right, as when I look at the whole node (shown below) it seems to do the whitespace/hint thing.wondering to strip out xsi as previously said.<GovTalkMessage xsi:schemaLocation="http://www.govtalk.gov.uk/CM/envelope http://xmlgw.companieshouse.gov.uk/v1-0/schema/Egov_ch-v2-0.xsd" xmlns="http://www.govtalk.gov.uk/CM/envelope" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:gt="http://www.govtalk.gov.uk/schemas/govtalk/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Paul Connolly