ITsolutionWizard
asked on
xml read and write
Below codes are tyring to get xml string from actual entire xml file. but now I want to put some conditions.
like I just want to get Application Name="A1" condition. so I suppose to get only Application Name= "A1" of course with all child nodes as well.
How can I modify it?
like I just want to get Application Name="A1" condition. so I suppose to get only Application Name= "A1" of course with all child nodes as well.
How can I modify it?
public static string convertToXmlString(string strFile)
{
//Q6: How to get xml string filter by applicationName? need help
// Load the xml file into XmlDocument object.
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(strFile);
}
catch (XmlException e)
{
Console.WriteLine(e.Message);
}
// Now create StringWriter object to get data from xml document.
StringWriter sw = new StringWriter();
XmlTextWriter xw = new XmlTextWriter(sw);
xmlDoc.WriteTo(xw);
return sw.ToString();
}
<?xml version="1.0" encoding="utf-8" ?>
<Applications>
<Application Name="A1" Script="">
<Q Id="1">
<Name>What is your favor color?</Name>
<Control>Select</Control>
<List>Red,Yellow</List>
<PdfFieldName>pdfColor</PdfFieldName>
<HtmlFieldName>selectFavorColor</HtmlFieldName>
<DefaultHtmlValue>Red</DefaultHtmlValue>
</Q>
<Q Id="2">
<Name>What is your favor car?</Name>
<Control>TextBox</Control>
<List></List>
<PdfFieldName>pdfCar</PdfFieldName>
<HtmlFieldName>textFavorCar</HtmlFieldName>
<DefaultHtmlValue></DefaultHtmlValue>
</Q>
<Q Id="3">
<Name>What is your favor hobby?</Name>
<Control>Checkbox</Control>
<List>Sport,Gamble</List>
<PdfFieldName>asdfasdf</PdfFieldName>
<HtmlFieldName>textFavorHobby</HtmlFieldName>
<DefaultHtmlValue>Sport</DefaultHtmlValue>
</Q>
</Application>
<Application Name="A2" Script="customScriptA2.js">
<Q Id="1">
<Name>What is your favor color?</Name>
<Control>Select</Control>
<List>Red,Yellow</List>
<PdfFieldName>pdfColor</PdfFieldName>
<HtmlFieldName>selectFavorColor</HtmlFieldName>
<DefaultHtmlValue>Red</DefaultHtmlValue>
</Q>
<Q Id="2">
<Name>What is your favor car?</Name>
<Control>TextBox</Control>
<List></List>
<PdfFieldName>pdfCar</PdfFieldName>
<HtmlFieldName>textFavorCar</HtmlFieldName>
<DefaultHtmlValue></DefaultHtmlValue>
</Q>
<Q Id="3">
<Name>What is your favor hobby?</Name>
<Control>CheckBox</Control>
<List>Sport,Gamble</List>
<PdfFieldName>asdfasdf</PdfFieldName>
<HtmlFieldName>textFavorHobby</HtmlFieldName>
<DefaultHtmlValue>Sport</DefaultHtmlValue>
</Q>
</Application>
</Applications>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Then you will need to wait for an expert that knows the old ways.
ASKER