Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / May 2008

Tip: Looking for answers? Try searching our database.

Namespace headache

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
egholm@gmail.com - 23 May 2008 10:32 GMT
I'm using the following XML:

---------------------------------------------------------------------------­--------------
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
       <Module Url="_catalogs/masterpage" Path="PageLayouts">
               <File Url="List.aspx" Type="GhostableInLibrary">
       </Module>
</Elements>
---------------------------------------------------------------------------­---------------

When I query the xml with the code below I get no results.
But if I remove the namespace "xmlns="http://schemas.microsoft.com/
sharepoint/"" from xml above everything works fine. I want to keep the
namespace in the xml. What do I do wrong?

XElement pagelayouts = XElement.Load("ProvisionedFiles.xml");
var query = from c in pagelayouts.Descendants("File") select c;

foreach(var q in query)
{
    //Something
}
egholm@gmail.com - 23 May 2008 10:41 GMT
Found a solution. This will do the trick:

XNamespace ns = "http://schemas.microsoft.com/sharepoint/";
XElement pagelayouts = XElement.Load("ProvisionedFiles.xml");
var query = from c in pagelayouts.Descendants(ns + "File") select c;

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.