Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Load, parse and selectnodes from unknown XMLdocument

$
0
0

I am aware about namespaces and how to add them to a namespace manager etc.
This is fine in an environment which I fully control.
However, I am now involved in a scenario where I pass xml data thru our system and on to a central validating hub. This data can have any number and kind of namespaces, totally unknown to me. If it is malformed, the central hub refuses it, and I send this information back to the originator. So far, so good.
Problems arise when the contents of the well-formed xml does not meet the requirements of the central hub. The central hub sends back an XPath string pointing to the error. If the original document used prefixes, then the Xpath string does - if the original had no prefixes, then the XPath string does not either.
My job now is to display the original text and highlight the error. In other words, I wish to parse a document without knowing what is in it, and then apply the Xpath string to find the error location.
Would have been nice, if the loaded XMLDcoument could have auto-detected the namespaces. This is disapointment number 1.
So, I have to read the document with an XMLReader first to extract the namespaces? Or use Regex?
Then I add the namespaces to an XMLDocument and load the thing all over again?
Then - oh dear - a namespace is declared with an empty prefix and selectsinglenode will not give any results = disapointment number 2.
So I manipulate the received XPath string and add my own prefixes? Wow. Is there no simple idiot method for this?
I somehow suspect that the central hub is using a very primitive parser - surely they are not going thru the same pain as I am? Would be great if somebody out there had some tips for me. This doesn't seem to me to be such a wild scenario...

TIA Elisabeth


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>