Created
February 17, 2018 13:40
-
-
Save joshi-kumar/118ba388fad30affe2d27d243946e12a to your computer and use it in GitHub Desktop.
C# xml attribute get
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var elemList = doc.GetElementsByTagName("spine")[0].ChildNodes; //solved by this | |
---------------------------------------------------------------- | |
http://stackoverflow.com/questions/18017692/c-sharp-get-values-from-xml-attributes | |
<?xml version="1.0" encoding="utf-8" ?> | |
<Config version="1.0.1.1" > | |
<Items> | |
<Item action="Create" filename="newtest.xml"/> | |
<Item action="Update" filename="oldtest.xml"/> | |
</Items> | |
</Config> | |
+++++++++++++++++++++++++++++++++++++++++++ | |
var xdoc = XDocument.Load(@newFile); | |
var items = from i in xdoc.Descendants("Item") | |
select new { | |
Action = (string)i.Attribute("action"), | |
FileName = (string)i.Attribute("fileName") | |
}; | |
foreach (var item in items) | |
{ | |
// use item.Action or item.FileName | |
} | |
------------------------------------------------------- | |
https://msdn.microsoft.com/en-us/library/7f0tkwcx(v=vs.80).aspx | |
<xs:simpleType name="qtyLimiter"> | |
<xs:restriction base="xs:positiveInteger"> | |
<xs:maxInclusive value="100" /> | |
</xs:restriction> | |
</xs:simpleType> | |
called xml attributes | |
---------------------------------------------------------- | |
http://stackoverflow.com/questions/933687/read-xml-attribute-using-xmldocument | |
XmlNodeList elemList = doc.GetElementsByTagName(...); | |
for (int i = 0; i < elemList.Count; i++) | |
{ | |
string attrVal = elemList[i].Attributes["SuperString"].Value; | |
} | |
------------------------------------------------------ | |
http://stackoverflow.com/questions/1600065/how-to-read-attribute-value-from-xmlnode-in-c | |
string employeeName = chldNode.Attributes["Name"].Value; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment