EDN Admin
Well-known member
Hi,
I have a xml file as shown. How to get the xscale and yscale values if Shirtcode and distance values are passed. Also please find my c# code below, it is not giving any result.
<?xml version="1.0" encoding="utf-8" ?><br/>
<Items><br/>
<Shirt Shcode="TRC001 <br/>
<Distance dist="2 <br/>
<Xscale>1</Xscale><br/>
<Yscale>1</Yscale><br/>
</Distance><br/>
<Distance dist="2.1 <br/>
<Xscale>1</Xscale><br/>
<Yscale>1</Yscale><br/>
</Distance><br/>
<Distance dist="2.2 <br/>
<Xscale>1</Xscale><br/>
<Yscale>1</Yscale><br/>
</Distance><br/>
</Shirt><br/>
<br/>
<Shirt Shcode="TRC002 <br/>
<Distance dist="2 <br/>
<Xscale>1</Xscale><br/>
<Yscale>1</Yscale><br/>
</Distance><br/>
<Distance dist="2.1 <br/>
<Xscale>1</Xscale><br/>
<Yscale>1</Yscale><br/>
</Distance><br/>
<Distance dist="2.2 <br/>
<Xscale>1</Xscale><br/>
<Yscale>1</Yscale><br/>
</Distance><br/>
</Shirt><br/>
</Items>
<pre class="prettyprint <pre class="prettyprint public static void GetAutoscaleData(string shirtCode,double distance)
{
XDocument data = XDocument.Load("AutoscaleData.xml");
var x = from sh in data.Descendants("Shirt")
where (sh.Attribute("Shcode").Value == shirtCode && Convert.ToDouble(sh.Element("Distance").Attribute("dist").Value) == distance)
select new
{
xscale = sh.Attribute("Xscale").Value,
yscale = sh.Attribute("Yscale").Value
};
foreach (var y in x)
{
string a = y.xscale;
string b = y.yscale;
}
}[/code] Thanks, Bharat. [/code]
View the full article
I have a xml file as shown. How to get the xscale and yscale values if Shirtcode and distance values are passed. Also please find my c# code below, it is not giving any result.
<?xml version="1.0" encoding="utf-8" ?><br/>
<Items><br/>
<Shirt Shcode="TRC001 <br/>
<Distance dist="2 <br/>
<Xscale>1</Xscale><br/>
<Yscale>1</Yscale><br/>
</Distance><br/>
<Distance dist="2.1 <br/>
<Xscale>1</Xscale><br/>
<Yscale>1</Yscale><br/>
</Distance><br/>
<Distance dist="2.2 <br/>
<Xscale>1</Xscale><br/>
<Yscale>1</Yscale><br/>
</Distance><br/>
</Shirt><br/>
<br/>
<Shirt Shcode="TRC002 <br/>
<Distance dist="2 <br/>
<Xscale>1</Xscale><br/>
<Yscale>1</Yscale><br/>
</Distance><br/>
<Distance dist="2.1 <br/>
<Xscale>1</Xscale><br/>
<Yscale>1</Yscale><br/>
</Distance><br/>
<Distance dist="2.2 <br/>
<Xscale>1</Xscale><br/>
<Yscale>1</Yscale><br/>
</Distance><br/>
</Shirt><br/>
</Items>
<pre class="prettyprint <pre class="prettyprint public static void GetAutoscaleData(string shirtCode,double distance)
{
XDocument data = XDocument.Load("AutoscaleData.xml");
var x = from sh in data.Descendants("Shirt")
where (sh.Attribute("Shcode").Value == shirtCode && Convert.ToDouble(sh.Element("Distance").Attribute("dist").Value) == distance)
select new
{
xscale = sh.Attribute("Xscale").Value,
yscale = sh.Attribute("Yscale").Value
};
foreach (var y in x)
{
string a = y.xscale;
string b = y.yscale;
}
}[/code] Thanks, Bharat. [/code]
View the full article