1
OK, I think I've grasped it now :)
case "Aircraft":
XElement auto = XElement.Load("auto.xml");
XElement aircraft = auto.Elements().Where(element => element.Name == "aircraft").First();
strReturn = aircraft.Attribute("command").Value;
strReturn = strReturn.Replace("@strAT", "'" + strAT + "'");
strReturn = strReturn.Replace("@strMK", "'" + strMK + "'");
break;
Accepted 0
Thanks a lot Vulpes :):):)
0
Thanks Vulpes for your kind help. It's my fault that I didn't make my point clear.
This is what I have in my XML file(Auto.XML)
<root>
<fault>
<text>Pending Fault found on</text>
<text>Repaired Fault on</text>
</fault>
<genere>
<text>Aircraft</text>
<text>Component</text>
<text>Subsystem</text>
</genere>
<aircraft command="SELECT h.FUNCTION_NO,Eng_Function_API.Get_Description(FUNCTION_NO) Func_desc
FROM hi_table h WHERE h.PRODUCT_NO = @strAT AND h.MODEL_NO = @strMK and parent_function_no is null;"
type="text">
</aircraft>
</root>
this is what I have in my codebehind file
public static string[] DBPopUp(string seccondSelection, string prefixText)
{
string[] arrReturn =null;
string strType = seccondSelection;
string strLikeChar = prefixText;
string strAT = "sample1";
string strMK = "sample2";
string strSN = "sample3";
string strReturn = string.Empty;
string strDynamic = string.Empty;
strDynamic = "Dynamic";
if ((strLikeChar != "") && (strType != "Aircraft")) strDynamic = strType + "_" + strDynamic;
else strDynamic = strType;
dynamicString = strLikeChar.ToUpper();
switch (strDynamic)
{
case "Aircraft_Dynamic":
break;
case "Aircraft": strReturn = // here I want to get the querystring written in the 'command' attribute of the 'aircraft' element of Auto.XML file and I also want to know how to replace @strAT and @strMK parameters
break;
// two more case statements will follow
}
so the querystring returned from the XML should be like this
SELECT h.FUNCTION_NO,IFSAPP.Eng_Function_API.Get_Description(FUNCTION_NO) Func_desc
FROM IFSAPP.PRODUCT_FUNCTION h WHERE h.PRODUCT_NO = 'sample1'(value of @strAT) AND h.MODEL_NO = 'sample2'(value of @strMK) and parent_function_no is null;
strReturn is the final querystring I am going to pass to database.

0
OK, what I'd suggest here is that, instead of sample 1, sample 2 etc, I'd use placeholders like you'd find in the String.Format or Console.WriteLine methods.
So within the GetQuery method you'd have:
strAT = "{0}";
strMK = "{1}";
strSN = "{2)";
On retrieving the query string from the method, you can then replace the placeholders with whatever values you like before writing the string to the XML file.
So you'd have something like this:
string strQuery = GlobalQuery.GetQuery(seccondSelection, prefixText);
strQuery = String.Format(strQuery, "some AT value", "some MK value");
Xlement auto = XElement.Load("auto.xml");
XElement aircraft = auto.Elements().Where(element => element.Name == "aircraft").First();
aircraft.Value = strQuery;
auto.Save("auto.xml");
To retrieve the query string from the XML file, you'd then need:
XElement auto = XElement.Load("auto.xml");
XElement aircraft = auto.Elements().Where(element => element.Name == "aircraft").First();
string strQuery = aircraft.Value;
0
Hi Vulpes,
I want to write the querystring in an existing XML file(Auto.xml).
this is the one I am having
<root>
<fault>
<text>Pending Fault found on</text>
<text>Repaired Fault on</text>
</fault>
<genere>
<text>Aircraft</text>
<text>Component</text>
<text>Subsystem</text>
</genere>
<aircraft>
" I want to write the querystring here and also I want to know how to replace the string values(highlited in blue) "
</aircraft>
</root>
Also please note that the XML file should retrun a querystring of type string.
I mean, in the below code
string strQuery = GlobalQuery.GetQuery(seccondSelection, prefixText);
GlobalQuery.GetQuery(seccondSelection, prefixText); // this returns a querystring, the same I want to achieve using XML(I want to pass those 2 string values to the XML and get the resultant querystring from XML and assign to strQuery).
0
Are you wanting to write the query string to an existing XML file or to a new one?
In either case, can you give a sample file and indicate under which node etc. the string is to be written.