linq-to-xml

Guidance on designing a solution - XML files vs database

I am thinking of storing bunch of data in XML files. Each file will has information about a distinct element lets say contacts. Now I am trying to do retrieve a contact based on some information eg: Find all the contacts who live in CA. How do I search for this information? Can I use something like LINQ. I am seeing XElement but does it ...

How to use short namespaces with XElements in .Net?

I am parsing an XML (RDF specifically) document, basically mapping it to some strongly typed objects in .Net. I have been using this really long syntax for selecting namespaces something like: ontology.Elements("{http://www.w3.org/1999/02/22-rdf-syntax-ns#}Property") What I really want to do is something like: ontology.Elements("rdf:...

How to check for existence of an element with XElement?

Notice in this code I am trying to check for the existence of the rdfs:range element before trying to select it. I do this to avoid a possible null reference exception at runtime. private readonly XNamespace rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; private readonly XNamespace rdfs = "http://www.w3.org/2000/01/rd...

Linq to RSS feed?

What I'm trying to do is take an RSS feel URL and, using LINQ, be able to write a query that will let me sort the subject line of the feed or sort the author line of the feed or even do 'WHERE' clauses that will let me filter by keywords for example. I know I can read the RSS feed, parse each element, put them into some sort of class ob...

Xdocument trying to create an XML file, having trouble with ListBox

So I have decided to use XDocument to create a XML file, which was working great until I came across a part where I have to find all the selected items in a ListBox. I am unsure how I should format this. XDocument xmlDoc = new XDocument( new XDeclaration("1.0", "utf-8", "yes"), new XComment("...

LINQ to XML:Is XNode query possible

I want to use LINQ to XML in Silverlight 3 since there is no XPath support. I have kind of got the hang of it. But the project I'm working on will not guarantee that all the XML tags I will be querying for will appear in the result XML file. Due to this I will not be able to query the overall file as XDocument becase the absence of the ...

Writing out namespace attributes in LINQ to XML

I'd like to write out the following XAML using LINQ to XML via C#. <Activity x:Class="WorkflowConsoleApplication1.Activity1" mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation"> </Activity> How do I specify the XNamespace for doing this to achieve the above output? ...

Can't read from xml into an <> using linq, get nulls

I have an XML file: <?xml version="1.0" encoding="us-ascii"?> <TestItems xmlns="http://www.blogger.com"&gt; <TestItem correct="0" incorrect="0"> <Question>question</Question> <Answer>answer</Answer> <Tags>test1;test2</Tags> </TestItem> <TestItem correct="0" incorrect="0"> <Question>question3</Question> <Answer...

Linq - Query a table and return results as XML

I have the following table structure: CREATE TABLE [Report].[MesReport]( [MesReportID] [int] IDENTITY(1,1) NOT NULL, [ParentID] [int] NOT NULL, [ReportTitle] [nvarchar](80) NOT NULL, [ReportName] [nvarchar](80) NOT NULL, [DatabaseServer] [nvarchar](80) NOT NULL, [DatabaseName] [nvarchar](50) NOT NULL, [Login]...

The ':' character, hexadecimal value 0x3A, cannot be included in a Attribute name.

Possible Duplicate: The : character, hexadecimal value 0x3A, cannot be included in a name I get that error when i use LinQ to XML .It's clear the error is due to reading XML and not linQ. Xml used: <Worksheet ss:Name="Location" ss:Protected="1"> I'm facing problem reading the Attribute value "ss:Name". ...

Process ITunes Playlist with LINQ XML

Im trying to pull tracks from the Itunes playlist which are unchecked in Itunes using LINQ XML for the first time. Tracks which are unchecked have a disabled attribute in the "ITunes Music Library.xml" file which is not present if the track in checked. Tryed using this code and serveral variants of but I either get all the songs or no...

How can I implement a label file for regions that integrates well with MVC application structure?

Background: I am working on a site that will be available in multiple regions. Each region can have a different language, or different spellings for the same language. We are planning on using an XML label file which will contain all the text that will be displayed for any given region. So regionA will load RegionALabels.xml and all o...

Linq to XML if/foreach with XElement

It seems I am having a bit of trouble with Linq to XML, I have looked for tutorials, but nothing really tells me about from, select, statements. I would like to know how to do a foreach/if statements with linq, if you have a tutorial please let me know. My problem right now is I only want a certain part put into my XML if the textbox h...

how to create dynamic Aspxmenu from database

*I work on C#.*I want to develop asp.net application which contains menu but menu items should be generated from database. My intension is that Administrator can change menu items by working only on database, no need to change front end any how. ** For example: Web page contains Menu as 1. Home 2. About Us 3. Contact Us ** ...

XDocument.Load losing Declaration

I have a XML template file like so <?xml version="1.0" encoding="us-ascii"?> <AutomatedDispenseResponse> <header shipmentNumber=""></header> <items></items> </AutomatedDispenseResponse> When I use XDocument.Load, for some reason the <?xml version="1.0" encoding="us-ascii"?> is dropped. How do I load the file into a XDocum...

How set XAttribute Value null.

XElement xml = new XElement("MyMenu", from c in db.Security_Module_Menus //where (c.ParentID == 0) orderby c.Menu_ID select new XElement("Item", new XAttribute("Text", c.Menu_Name), new XAttribute("NavigateUrl", c.Target_UR...

How to create Sub Item on Xml Linq

In northwind database .I use order and orderDetails table.I want to create a xml file ,where order show on Item tag on XML and orderdetails show on sub item.Suppose orderid=1 show on Item tag then orderdetais**table information of **OrderID=1 show on sub-Item. XElement xml = new XElement("MyMenu", from c in db.Ord...

how to get text representation from XDocument?

XmlDocument class has a property "Text" whicn allows you to get text representation of XML (that is only the text part collected within all the nodes), how do I get it from XDocument? ...

Help me improve a OpenXML linq-to-xml query!

Guess people need some experience with Linq-to-xml and knowledge of the build of a openXML word document. I have this Linq to XML query that's supposed to find Content Controls. It works most of the time but I think it's still just juryrigged and not proper. How it works, if I understand correctly, is that it checks StdRuns and finds i...

vb.net linq to xml syntax for documents with xml namespace

I'm trying to grasp the linq to xml 'inline query syntax' features of VB.Net First I tried with this simple xml file: <?xml version="1.0" encoding="utf-8" ?> <Root> <Child Name="somename"> <SomeAttribute>SomeValue</SomeAttribute> </Child> </Root> This xml, when loaded in an XDocument, can be loaded...