Team -

Please forgive my ignorance here, I am very new to xml coding. Basic situation is if I run the following code:

Dim feedXML As XDocument = XDocument.Load("c:\Feeds.xml")
        Dim bubba = From Feedmain In feedXML.Descendants("Feed") _
        Where (Feedmain.Attribute("status") Is Nothing) OrElse (Feedmain.Attribute("status").Value <> "disabled") _
        Select Name = Feedmain.Element("Name").Value, _
        Url = Feedmain.Element("otherinfo").Element("Url").Value

I can later bind the data into a gridview and get two lovely columns of text. But I don't want two columns, I want one soooooooo. I do this.

Dim feedXML As XDocument = XDocument.Load("c:\Feeds.xml")
        Dim bubba = From Feedmain In feedXML.Descendants("Feed") _
        Where (Feedmain.Attribute("status") Is Nothing) OrElse (Feedmain.Attribute("status").Value <> "disabled") _
        Select Name = Feedmain.Element("Name").Value

Then when I bind to my datagridview I get a single column but it is giving me a char count on the line of text. What am I missing?

If I have totally made myself unclear please let me know!

Could someone point me in the right direction please?

Dewayne

Recommended Answers

All 2 Replies

Try this,

Dim feedXML As XDocument = XDocument.Load("c:\Feeds.xml")
        Dim bubba = From Feedmain In feedXML.Descendants("Feed") _
        Where (Feedmain.Attribute("status") Is Nothing) OrElse (Feedmain.Attribute("status").Value <> "disabled") _
        Select New With {.Name = Feedmain.Element("Name").Value()}

        DataGridView1.DataSource = bubba.ToList()

worked perfect! Thank you for the hand!

Dewayne

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.