2 Replies - 916 Views - Last Post: 23 December 2009 - 06:32 AM Rate Topic: -----

#1 Adkins  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 66
  • View blog
  • Posts: 560
  • Joined: 27-October 09

[RESOLVED] Linq to XML

Post icon  Posted 23 December 2009 - 06:11 AM

I have a WIX XML document that contains 2,000+ file tags. I am trying to make a program using LINQ to XML that can update an attribute of each file tag. My code is as follows for loading the current attributes into a dictionary.

 XElement root = XElement.Load(filePath);
 XNamespace wix = @"http://schemas.microsoft.com/wix/2006/wi";

 IEnumerable<string> fileId =
       from seg in root.Descendants(wix + "File")
       select (string)seg.Attribute(wix + "Id");

 IEnumerable<string> path =
       from seg in root.Descendants(wix + "File")
       select (string)seg.Attribute(wix + "Source");

 string[] Position1 = fileId.ToArray();
 string[] Position2 = path.ToArray();

 for (int i = 0; i < Position1.Length; i++)
 {
       xmlDataRaw.Add(Position1[i], Position2[i]);
 }



now the problem is that my program says that the IEnumerable fileID and path both contain only "null" but I know that the file tag exists and that every one of them has an ID and Source attribute. Thoughts?

Is This A Good Question/Topic? 0
  • +

Replies To: [RESOLVED] Linq to XML

#2 Adkins  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 66
  • View blog
  • Posts: 560
  • Joined: 27-October 09

Re: [RESOLVED] Linq to XML

Posted 23 December 2009 - 06:24 AM

Got it figured out! The attribute doesn't need a namespace attached to it! I should have known it was that simple! I feel better now. B)
Was This Post Helpful? 0
  • +
  • -

#3 Adkins  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 66
  • View blog
  • Posts: 560
  • Joined: 27-October 09

Re: [RESOLVED] Linq to XML

Posted 23 December 2009 - 06:32 AM

Got it figured out! The attribute doesn't need a namespace attached to it! I should have known it was that simple! I feel better now. B)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1