@Shabbir Daruwala , Welcome to Microsoft Q&A,
You can save your xml text to a xml file. Based on my test, the xml you provided is need to modify, the following xml is an example.
<?xml version="1.0" encoding="UTF-8"?>
<AttributeValues xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<EntityAttributeValue>
<Value />
<Attribute>
<Id>1</Id>
<Name>Internet Filter 1</Name>
<AttributeType>other</AttributeType>
</Attribute>
<AttributeValueId>0</AttributeValueId>
<ProductTypeId xsi:nil="true" />
</EntityAttributeValue>
<EntityAttributeValue>
<Value />
<Attribute>
<Id>0</Id>
<Name>Product Type</Name>
<AttributeType>category</AttributeType>
</Attribute>
<AttributeValueId>0</AttributeValueId>
<ProductTypeId xsi:nil="true" />
</EntityAttributeValue>
<EntityAttributeValue>
<Value>Beauty</Value>
<Attribute>
<Id>1</Id>
<Name>Department</Name>
<AttributeType>global</AttributeType>
</Attribute>
<AttributeValueId>7</AttributeValueId>
<ProductTypeId xsi:nil="true" />
</EntityAttributeValue>
<EntityAttributeValue>
<Value>Women</Value>
<Attribute>
<Id>2</Id>
<Name>Gender</Name>
<AttributeType>global</AttributeType>
</Attribute>
<AttributeValueId>1</AttributeValueId>
<ProductTypeId xsi:nil = "true" />
</EntityAttributeValue>
<EntityAttributeValue>
<Value>CHANEL</Value>
<Attribute>
<Id>8</Id>
<Name>Brand</Name>
<AttributeType>global</AttributeType>
</Attribute>
<AttributeValueId>2958</AttributeValueId>
<ProductTypeId xsi:nil="true" />
</EntityAttributeValue>
</AttributeValues>
Then, you could refer to the following code to use linq to xml to get the value you wanted.
private void button1_Click(object sender, EventArgs e)
{
XDocument doc = XDocument.Load("D:\\test.xml");
var values = doc.Descendants("EntityAttributeValue").Select(i=>i.Element("Attribute").Element("Name").Value);
foreach (var item in values)
{
listBox1.Items.Add(item.ToString());
}
}
Result:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.