Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 

Go Back   XSL - XML - RSS Forums > XML General > .NET and XML

Tags:



Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-28-2008, 01:00 PM
Martin Honnen
 
Posts: n/a

Default Re: Can someone help me to understand schema locations?



SeanInSeattle wrote:
> Ah, yes. I appreciate that. Though, which one is the URI in my example xml?
> Is it the p1:schemalocation value altogether, or just the "http://[...]", or
> is it the xmlns1 value?


Well the code I suggested simply takes the URI from the DocumentElement,
that is why I suggested to use
mgr.AddNamespace("df", doc.DocumentElement.NamespaceURI);
where "df" is a prefix you can freely choose and where the second
argument simply reads out the NamespaceURI from the DocumentElement. In
the sample you posted that URI is "Data_Feed" so assuming that is how
your real XML looks you could also use
mgr.AddNamespace("df", "Data_Feed");
but the code I posted works perfectly even when the XML changes while
the last suggestion would hard code the URI in the C#.

> Here's my code:
>
> [code]
> try {
> XmlDocument xDoc = new XmlDocument();
> xDoc.Load(XMLDoc_URL);
> System.Xml.XmlNamespaceManager xmlnsManager = new
> System.Xml.XmlNamespaceManager(xDoc.NameTable);
> xmlnsManager.AddNamespace(strDataFeedName, xDoc.DocumentElement.NamespaceURI);


Without seeing the value of strDataFeedName

> foreach (System.Xml.XmlNode xnDetail in
> xDoc.DocumentElement.SelectNodes(XPathToData, xmlnsManager))


and XPathToData it is not possible to tell whether your code works.





--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Contact Us -|- XSL - XML - RSS Forums -|- Archive -|- Top -|-Rules/Disclaimer-|-Help/Support -|-Advertise
© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
All times are GMT. The time now is 12:18 PM.
Style Developed by Epic Designz