Due to get some Values from HTML or for XML there we need to Read XML Attributes Values from given string in C#.
There is the sample code below; which is using System.Xml.Linq.
which will help you to over come this problem. and read the XML attribute value through c#
Suppose you have the XML attributes as below; There we are finding the description from Given attributes.
There is the sample code below; which is using System.Xml.Linq.
which will help you to over come this problem. and read the XML attribute value through c#
Suppose you have the XML attributes as below; There we are finding the description from Given attributes.
string
str = @"<label description='My Button Text'
languagecode='5001' />";
static void
Main(string[] args)
{
string str = @"<label
description='My Button Text' languagecode='5001' />";
System.Xml.Linq.XElement stry = System.Xml.Linq.XElement.Parse(str);
string value = (string)stry.Attribute("description");
Console.WriteLine(value);
}
Output will be "My Button Text"
For DOM Element (get attributes in javascript)
To Read the the Attributes of dom element in Javascript it is simple by using the .getAttribute Method;
1. var x =
document.getElementById("inpName").getAttribute("Type");
To check for multiple control at one time as;
2. var x = document.getElementsByTagName("img")[0].getAttribute("src");
No comments:
Post a Comment