Get Attribute with namespace : Attribute « XML LINQ « C# / C Sharp






Get Attribute with namespace

  

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using System.Reflection;
using System.Xml.Linq;

class Program {
    static void Main(string[] args) {
        XElement xml = XElement.Load("Hello_XLINQ.xml");
        XNamespace w = "http://schemas.microsoft.com/office/word/2003/wordml";

        XElement defaultFonts = xml.Descendants(w + "defaultFonts").First();
        Console.WriteLine("Default Fonts: {0}", (string)defaultFonts.Attribute(w + "ascii"));

    }
}

   
  








Related examples in the same category

1.Accessing an Element's Attributes Using the Attributes Method
2.Calling the Remove
3.Accessing an Element's First Attribute with the FirstAttribute Property
4.Accessing the Next Attribute with the NextAttribute Property
5.Accessing the Previous Attribute with the PreviousAttribute Property
6.Accessing the Last Attribute with the LastAttribute Property
7.Accessing an Attribute with the Attribute Method
8.Accessing All of an Element's Attributes with the Attributes Method
9.Removing an Attribute
10.Removing All of an Element's Attributes
11.Changing an Attribute's Value
12.Using SetAttributeValue to Add, Delete, and Update Attributes
13.Calling the First Attributes Prototype
14.Calling the Second Attributes Prototype
15.XElement.Attribute returns the XAttribute of this XElement that has the specified XName.
16.XElement.Attributes returns a collection of attributes of this element.
17.Returns a filtered collection of attributes of this element.
18.XElement.FirstAttribute gets the first attribute of this element.
19.XElement.HasAttributes gets a value indicating whether this element as at least one attribute.
20.XElement.LastAttribute gets the last attribute of this element.
21.XElement.RemoveAll removes nodes and attributes from this XElement.
22.XElement.RemoveAttributes removes the attributes of this XElement.
23.XElement.ReplaceAll replaces the child nodes and the attributes of this element
24.XElement.ReplaceAttributes replaces the attributes of this element with the specified content.
25.XElement.SetAttributeValue sets the value of an attribute, adds an attribute, or removes an attribute.