I need to create a WebService that takes the name of a city as input and returns Location, Country and Weather information of the City. The thing is that the ID, Location, Country is in one XML file and all weather details in another.
<City>
<ID>city1</ID>
<Grid_ref>NG 895608</Grid_ref>
<Name>Berlin</Name>
<Country>Germany</Country>
</City>
<cityWeather>
<ID>city1</ID>
<temperature>20</temperature>
<wind>2</wind>
</cityWeather>
Using c# is it possible to merge everything into 1 file using ID or is there some other way I can do it? I would then search the XML file once, as having 2 different files mixes me up.
You can use DataSet. I suppose you have two XML files. CityWeather.xml et City.xml, you can make this
try
{
XmlTextReader xmlreader1 = new XmlTextReader("C:\\Books1.xml");
XmlTextReader xmlreader2 = new XmlTextReader("C:\\Books2.xml");
DataSet ds = new DataSet();
ds.ReadXml(xmlreader1);
DataSet ds2 = new DataSet();
ds2.ReadXml(xmlreader2);
ds.Merge(ds2);
ds.WriteXml("C:\\Books.xml");
Console.WriteLine("Completed merging XML documents");
}
catch (System.Exception ex)
{
Console.Write(ex.Message);
}
Console.Read();
You can make any changes that meet your need
hope it helps
Use add
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string cityXML =
"<Root>" +
"<City>" +
"<ID>city1</ID>" +
"<Grid_ref>NG 895608</Grid_ref>" +
"<Name>Berlin</Name>" +
"<Country>Germany</Country>" +
"</City>" +
"<City>" +
"<ID>city2</ID>" +
"<Grid_ref>F 5608</Grid_ref>" +
"<Name>Paris</Name>" +
"<Country>France</Country>" +
"</City>" +
"<City>" +
"<ID>city3</ID>" +
"<Grid_ref>RR 608</Grid_ref>" +
"<Name>Rome</Name>" +
"<Country>Italy</Country>" +
"</City>" +
"</Root>";
XElement cities = XElement.Parse(cityXML);
string weatherXML =
"<Root>" +
"<cityWeather>" +
"<ID>city1</ID>" +
"<temperature>20</temperature>" +
"<wind>2</wind>" +
"</cityWeather>" +
"<cityWeather>" +
"<ID>city2</ID>" +
"<temperature>30</temperature>" +
"<wind>3</wind>" +
"</cityWeather>" +
"<cityWeather>" +
"<ID>city3</ID>" +
"<temperature>40</temperature>" +
"<wind>4</wind>" +
"</cityWeather>" +
"</Root>";
XElement weather = XElement.Parse(weatherXML);
List<XElement> cityList = cities.Descendants("City").ToList();
foreach(XElement city in cityList)
{
XElement matchedCity = weather.Descendants("cityWeather").Where(x =>
x.Element("ID").Value == city.Element("ID").Value).FirstOrDefault();
if(matchedCity != null) city.Add(matchedCity);
}
}
}
}
Related
I need to write GPS-Data in different XMLfiles. The files need to have the following format:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx>
<metadata>
<time>YYYY-MM-DDTHH:MM:SSZ</time>
</metadata>
<trk>
<name>YYYY-MM-DDTHH:MM:SSZ</name>
<trkseg>
<trkpt lat="12.1795" lon="12.3456">
<ele>-46.97</ele>
<time>YYYY-MM-DDTHH:MM:SSZ</time>
</trkpt>
// more trkpt
</trkseg>
</trk>
</gpx>
I tried to do it with an XMLwriter. At first it constructs the part till trkpt.That works. The XmlWriterSettings were included because the Error told me to use ConformanceLevel "Auto" or "fregmented" ,but that didn't solve my issue.
XmlWriterSettings setting = new XmlWriterSettings();
setting.ConformanceLevel = ConformanceLevel.Auto;
setting.Indent = true;
DateTime localDate = DateTime.Now;
xmlWriter[0] = XmlWriter.Create("testbase.xml", setting);
for (int i = 1; i < (numOfXMLWriter); i++)
{
xmlWriter[i] = XmlWriter.Create(test[i].Text, setting);
}
int tmp = 0;
foreach (XmlWriter writer in xmlWriter)
{
writer.WriteStartDocument(true);
writer.WriteStartElement("gpx");
writer.WriteStartElement("metadata");
writer.WriteStartElement("time");
writer.WriteString(localDate.Year + "-" + localDate.Month + "-" + localDate.Day + "T" + localDate.Hour + ":" + localDate.Minute + ":" + localDate.Second);
writer.WriteEndElement(); //time
writer.WriteEndElement(); //metadata
//trk + name
writer.WriteStartElement("trkseg");
}
Later the received GPS-Data is written as individual trkpt.
xmlWriter[id].WriteStartElement("trkpt");
xmlWriter[id].WriteAttributeString("lat", splitData[4]);
xmlWriter[id].WriteAttributeString("lon", splitData[6]);
xmlWriter[id].WriteStartAttribute("ele");
xmlWriter[id].WriteString("0");
xmlWriter[id].WriteEndElement(); //</ele>
xmlWriter[id].WriteStartElement("time");
xmlWriter[id].WriteString(splitData[10][4] + splitData[10][5] + "-" + splitData[10][2] + splitData[10][3] + "-" + splitData[10][0] + splitData[10][1] + "T" + splitData[2][0] + splitData[2][1] + ":" + splitData[2][2] + splitData[2][3] + ":" + splitData[2][4] + splitData[2][5] + "Z");
xmlWriter[id].WriteEndElement(); //</time>
xmlWriter[id].WriteEndElement(); //</trkpt>
The Error says:
InvalidOperationException: "Token StartElement in state EndRootElement would result in an invalid XML document”
I think this is because the XMLwriter Closes all the nodes atomatically and later i try to add another Node on root Level. Is there a possibility to stap the writer from ending the document on it's own?
Thanks for your help!
Jonas
Using xml linq
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication1
{
class Program
{
const string FILENAME = #"c:\temp\test.xml";
static void Main(string[] args)
{
string header = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?><gpx></gpx>";
XDocument doc = XDocument.Parse(header);
XElement gpx = doc.Root;
gpx.Add(new object[] {
new XElement("metadata"), new XElement("time", DateTime.Now.ToString("yyyy-MM-ddthh:mm:ssz")),
new XElement("trk", new object[] {
new XElement("name", DateTime.Now.ToString("yyyy-MM-ddthh:mm:ssz")),
new XElement("trksseg", new object[] {
new XElement("trkpt", new object[] {
new XAttribute("lat", 12.1795),
new XAttribute("lon", 12.3456),
new XElement("ele", -46.97),
new XElement("time",DateTime.Now.ToString("yyyy-MM-ddthh:mm:ssz")),
})
})
})
});
}
}
}
I have been looking for some time now and have not been able to find this. How can I set my program up to write or update a file from multiple users but only one group is allowed to open the read what is in the folder?
class Log_File
{
string LogFileDirectory = #"\\server\boiseit$\TechDocs\Headset Tracker\Weekly Charges\Log\Log Files";
string PathToXMLFile = #"\\server\boiseit$\scripts\Mikes Projects\Headset-tracker\config\Config.xml";
string AdditionToLogFile = #"\Who.Did.It_" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Year + ".txt";
XML XMLFile = new XML();
public void ConfigCheck()
{
if (!File.Exists(PathToXMLFile))
{
XMLFile.writeToXML(PathToXMLFile, LogFileDirectory + AdditionToLogFile);
}
}
public void CreateLogFile()
{
if (Directory.GetFiles(LogFileDirectory).Count() == 0)
{
XMLFile.writeToXML(PathToXMLFile, LogFileDirectory + AdditionToLogFile);
CreateFileOrAppend("");
}
else if (!File.Exists(XMLFile.readingXML(PathToXMLFile)))
{
XMLFile.writeToXML(PathToXMLFile, LogFileDirectory + AdditionToLogFile);
CreateFileOrAppend("");
}
else
{
FileInfo dateOfLastLogFile = new FileInfo(XMLFile.readingXML(PathToXMLFile));
DateTime dateOfCreation = dateOfLastLogFile.CreationTime;
if (dateOfLastLogFile.CreationTime <= DateTime.Now.AddMonths(-1))
{
XMLFile.writeToXML(PathToXMLFile, LogFileDirectory + AdditionToLogFile);
CreateFileOrAppend("");
}
}
}
public void CreateFileOrAppend(string whoDidIt)
{
using (IsolatedStorageFile storage = IsolatedStorageFile.GetStore((IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly | IsolatedStorageScope.User), null, null))
{
using (StreamWriter myWriter = new StreamWriter(XMLFile.readingXML(PathToXMLFile), true))
{
if (whoDidIt == "")
{
}
else
{
myWriter.WriteLine(whoDidIt);
}
}
}
}
This is my path where it needs to go. I have the special permission to open and write to the folder but my co workers do not. I am not allow to let them have this permission.
If I where to set up a database how would i change this code
LoggedFile.CreateFileOrAppend(Environment.UserName.ToUpper() + "-" + Environment.NewLine + "Replacement Headset To: " + AgentName + Environment.NewLine + "Old Headset Number: " + myDatabase.oldNumber + Environment.NewLine + "New Headset Number: " + HSNumber + Environment.NewLine + "Date: " + DateTime.Now.ToShortDateString() + Environment.NewLine);
I need it to pull current user, the agents name that is being affected the old headset and the new headset, and the time it took place.
While you create file, you have to set access rules to achieve your requirements. .
File.SetAccessControl(string,FileSecurity)
The below link has example
https://msdn.microsoft.com/en-us/library/system.io.file.setaccesscontrol(v=vs.110).aspx
Also the "FileSecurity" class object, which is an input parameter, has functions to set access rules, including group level control.
Below link has example
https://msdn.microsoft.com/en-us/library/system.security.accesscontrol.filesecurity(v=vs.110).aspx
This question will be opened under a new question since I am going to take a different route for recording the data I need Thank you all for the help
I am trying to user Linq to XML to pull out a value from some xml based on another value..
Here is my xml
<Lead>
<ID>1189226</ID>
<Client>
<ID>8445254</ID>
<Name>City of Lincoln Council</Name>
</Client>
<Contact>
<ID>5747449</ID>
<Name>Fred Bloggs</Name>
</Contact>
<Owner>
<ID>36612</ID>
<Name>Joe Bloggs</Name>
</Owner>
<CustomFields>
<CustomField>
<ID>31961</ID>
<Name>Scotsm_A_n_Authority_Good</Name>
<Boolean>true</Boolean>
</CustomField>
<CustomField>
<ID>31963</ID>
<Name>Scotsma_N_Need Not Want</Name>
<Boolean>false</Boolean>
</CustomField>
</CustomFields>
So, for example, I want to try and get the value of <Boolean> in the <CustomField> where <Name> equals "Scotsm_A_n_Authority_Good" which should be "true"
I have tried the following:
var xmlAnswers = xe.Element("CustomFields").Element("CustomField").Element("Scotsm_A_n_Authority_Good");
But I get an error saying that:
The ' ' character, hexadecimal value 0x20, cannot be included in a name...
Can anyone help please?
You're looking for the wrong thing at the moment. You should be looking for a CustomField element with a Name element with the specified value:
string target = "Scotsm_A_n_Authority_Good"; // Or whatever
var xmlAnswers = xe.Element("CustomFields")
.Elements("CustomField")
.Where(cf => (string) cf.Element("Name") == target);
This will give you all the matching CustomField elements. You can then get the Boolean value with something like:
foreach (var answer in xmlAnswers)
{
int id = (int) answer.Element("ID");
bool value = (bool) answer.Element("Boolean");
// Use them...
}
(You could extract the ID and value in the LINQ query of course...)
Here is an xml linq solution
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication93
{
class Program
{
static void Main(string[] args)
{
string xml =
"<Lead>" +
"<ID>1189226</ID>" +
"<Client>" +
"<ID>8445254</ID>" +
"<Name>City of Lincoln Council</Name>" +
"</Client>" +
"<Contact>" +
"<ID>5747449</ID>" +
"<Name>Fred Bloggs</Name>" +
"</Contact>" +
"<Owner>" +
"<ID>36612</ID>" +
"<Name>Joe Bloggs</Name>" +
"</Owner>" +
"<CustomFields>" +
"<CustomField>" +
"<ID>31961</ID>" +
"<Name>Scotsm_A_n_Authority_Good</Name>" +
"<Boolean>true</Boolean>" +
"</CustomField>" +
"<CustomField>" +
"<ID>31963</ID>" +
"<Name>Scotsma_N_Need Not Want</Name>" +
"<Boolean>false</Boolean>" +
"</CustomField>" +
"</CustomFields>" +
"</Lead>";
XDocument doc = XDocument.Parse(xml);
//to get all customField
var results = doc.Descendants("CustomField").Select(x => new
{
id = (int)x.Element("ID"),
name = (string)x.Element("Name"),
boolean = (Boolean)x.Element("Boolean")
}).ToList();
//to get specific
XElement Scotsm_A_n_Authority_Good = doc.Descendants("CustomField")
.Where(x => ((string)x.Element("Name") == "Scotsm_A_n_Authority_Good") && (Boolean)(x.Element("Boolean"))).FirstOrDefault();
}
}
}
I am still getting warmed up with NetSuite and have come across an issue I can't crack.
I am building a C# function to pull information from an XML soap response from NetSuite. This XML is the result of a saved search call which contains a section that is a join titled customSearchJoin that I am unsure how to access. Below I will show the XML section and my attempts to access it in the C# function.
I am attempting to access the field with the value of 091736418
XML segment:
<platformCore:searchRow xsi:type="tranSales:TransactionSearchRow" xmlns:tranSales="urn:sales_2014_1.transactions.webservices.netsuite.com">
<tranSales:basic xmlns:platformCommon="urn:common_2014_1.platform.webservices.netsuite.com">
<platformCommon:dateCreated>
<platformCore:searchValue>2015-12-17T08:43:00.000-08:00</platformCore:searchValue>
</platformCommon:dateCreated>
<platformCommon:entity>
<platformCore:searchValue internalId="615"/>
</platformCommon:entity>
</tranSales:basic>
<tranSales:customerMainJoin xmlns:platformCommon="urn:common_2014_1.platform.webservices.netsuite.com">
<platformCommon:altName>
<platformCore:searchValue>Some Specific Customer</platformCore:searchValue>
</platformCommon:altName>
</tranSales:customerMainJoin>
<tranSales:itemJoin xmlns:platformCommon="urn:common_2014_1.platform.webservices.netsuite.com">
<platformCommon:itemId>
<platformCore:searchValue>Some Product</platformCore:searchValue>
</platformCommon:itemId>
</tranSales:itemJoin>
<tranSales:customSearchJoin xmlns:platformCommon="urn:common_2014_1.platform.webservices.netsuite.com">
<platformCommon:customizationRef internalId="167" scriptId="custrecord_itmfulfillmentid"/>
<platformCommon:searchRowBasic xsi:type="platformCommon:CustomRecordSearchRowBasic">
<platformCommon:recType internalId="25"/>
<platformCommon:customFieldList>
<platformCore:customField xsi:type="platformCore:SearchColumnStringCustomField" scriptId="custrecord_ssccbarcode" internalId="169">
<platformCore:searchValue>091736418</platformCore:searchValue>
</platformCore:customField>
</platformCommon:customFieldList>
</platformCommon:searchRowBasic>
</tranSales:customSearchJoin>
</platformCore:searchRow>
C# function:
private void testCustomJoinSearch() {
TransactionSearchAdvanced transSearchAdv = new TransactionSearchAdvanced
{
savedSearchScriptId = "customsearch_savedSearchID"
};
SearchResult searchResult = _service.search(transSearchAdv);
if (searchResult.status.isSuccess)
{
Console.WriteLine("Search Success");
foreach (TransactionSearchRow transSearchRow in searchResult.searchRowList)
{
// declare vars
string transInternalID = "";
string ssccBarcode = "";
//normal field
transInternalID = transSearchRow.basic. internalId[0].searchValue.internalId.ToString();
//joined and custom field ? Not sure this loop is correct
foreach (CustomSearchRowBasic customBasicSearchRow in transSearchRow.customSearchJoin)
{
// ????
};
Console.WriteLine("transInternalID {0}", transInternalID);
Console.WriteLine("ssccBarcode {0}", ssccBarcode);
} // end main search row
}
else
{
Console.WriteLine("Search Failure");
Console.WriteLine(searchResult.status.statusDetail);
}
}
Try xml linq. I fixed your xml that was missing some namespace definitions so I added root and then closed the end tags platformCore:searchRow and root.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication70
{
class Program
{
static void Main(string[] args)
{
string xml =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
"<Root xmlns:platformCore=\"abc\" xmlns:xsi=\"def\">" +
"<platformCore:searchRow xsi:type=\"tranSales:TransactionSearchRow\" xmlns:tranSales=\"urn:sales_2014_1.transactions.webservices.netsuite.com\">" +
"<tranSales:basic xmlns:platformCommon=\"urn:common_2014_1.platform.webservices.netsuite.com\">" +
"<platformCommon:dateCreated>" +
"<platformCore:searchValue>2015-12-17T08:43:00.000-08:00</platformCore:searchValue>" +
"</platformCommon:dateCreated>" +
"<platformCommon:entity>" +
"<platformCore:searchValue internalId=\"615\"/>" +
"</platformCommon:entity>" +
"</tranSales:basic>" +
"<tranSales:customerMainJoin xmlns:platformCommon=\"urn:common_2014_1.platform.webservices.netsuite.com\">" +
"<platformCommon:altName>" +
"<platformCore:searchValue>Some Specific Customer</platformCore:searchValue>" +
"</platformCommon:altName>" +
"</tranSales:customerMainJoin>" +
"<tranSales:itemJoin xmlns:platformCommon=\"urn:common_2014_1.platform.webservices.netsuite.com\">" +
"<platformCommon:itemId>" +
"<platformCore:searchValue>Some Product</platformCore:searchValue>" +
"</platformCommon:itemId>" +
"</tranSales:itemJoin>" +
"<tranSales:customSearchJoin xmlns:platformCommon=\"urn:common_2014_1.platform.webservices.netsuite.com\">" +
"<platformCommon:customizationRef internalId=\"167\" scriptId=\"custrecord_itmfulfillmentid\"/>" +
"<platformCommon:searchRowBasic xsi:type=\"platformCommon:CustomRecordSearchRowBasic\">" +
"<platformCommon:recType internalId=\"25\"/>" +
"<platformCommon:customFieldList>" +
"<platformCore:customField xsi:type=\"platformCore:SearchColumnStringCustomField\" scriptId=\"custrecord_ssccbarcode\" internalId=\"169\">" +
"<platformCore:searchValue>091736418</platformCore:searchValue>" +
"</platformCore:customField>" +
"</platformCommon:customFieldList>" +
"</platformCommon:searchRowBasic>" +
"</tranSales:customSearchJoin>" +
"</platformCore:searchRow>" +
"</Root>";
XDocument doc = XDocument.Parse(xml);
string searchvalue = doc.Descendants().Where(x => x.Name.LocalName == "customSearchJoin")
.Descendants().Where(y => y.Name.LocalName == "searchValue").Select(z => (string)z).FirstOrDefault();
}
}
}
I believe it is something like this:
foreach (CustomSearchRowBasic customBasicSearchRow in transSearchRow.customSearchJoin) {
// ????
CustomRecordSearchRowBasic itmfulfillmentidRecord = customBasicSearchRow.searchRowBasic as CustomRecordSearchRowBasic;
foreach(SearchColumnCustomField customField in itmfulfillmentidRecord.customFieldList) {
if (customField.scriptId == "custrecord_ssccbarcode") {
SearchColumnStringCustomField stringField = customField as SearchColumnStringCustomField;
string itmfulfillmentid = stringField.searchValue;
}
}
}
I have used the following code before but my xml is different this time:
protected string ReturnXmlValue(XmlDocument myXDoc, string field)
{
var retval = string.Empty;
try
{
var node = myXDoc.GetElementsByTagName(field);
if (node.Count > 0)
{
var xmlNode = node.Item(0);
if (xmlNode != null)
{
retval = xmlNode.InnerText;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
throw;
}
return retval;
}
Here is an example of my xml file dummied down a bit:
<RichDBDS>
<TrxDetailCard>
<TRX_HD_Key>18683435</TRX_HD_Key>
<Date_DT>2015-10-22T21:32:00.233+00:00</Date_DT>
<TRX_Card_Key>15263569</TRX_Card_Key>
<Total_Amt_MN>22.0000</Total_Amt_MN>
<Result_CH>0 </Result_CH>
<Result_Txt_VC>APPROVED</Result_Txt_VC>
<Approval_Code_CH>0943253</Approval_Code_CH>
</TrxDetailCard>
<TrxDetailCard>
<TRX_HD_Key>18683825</TRX_HD_Key>
<Date_DT>2015-10-23T21:32:00.233+00:00</Date_DT>
<TRX_Card_Key>15263569</TRX_Card_Key>
<Total_Amt_MN>32.0000</Total_Amt_MN>
<Result_CH>0 </Result_CH>
<Result_Txt_VC>APPROVED</Result_Txt_VC>
<Approval_Code_CH>093389</Approval_Code_CH>
</TrxDetailCard>
</RichDBDS>
I've not worked with xml much so I'm not sure how to search this for a specific amount. I can have several TrxDetailCards. I know how to get amount when I only have one TrxDetailCard but I need to return the TrxDetailCard for the hits on the amount that I need.
So if I am looking for the TrxDetailCard that is 32.00, I need the method to return:
<TrxDetailCard>
<TRX_HD_Key>18683825</TRX_HD_Key>
<Date_DT>2015-10-23T21:32:00.233+00:00</Date_DT>
<TRX_Card_Key>15263569</TRX_Card_Key>
<Total_Amt_MN>32.0000</Total_Amt_MN>
<Result_CH>0 </Result_CH>
<Result_Txt_VC>APPROVED</Result_Txt_VC>
<Approval_Code_CH>093389</Approval_Code_CH>
</TrxDetailCard>
How would I go about doing this?
Try this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string xml =
"<RichDBDS>" +
"<TrxDetailCard>" +
"<TRX_HD_Key>18683435</TRX_HD_Key>" +
"<Date_DT>2015-10-22T21:32:00.233+00:00</Date_DT>" +
"<TRX_Card_Key>15263569</TRX_Card_Key>" +
"<Total_Amt_MN>22.0000</Total_Amt_MN>" +
"<Result_CH>0 </Result_CH>" +
"<Result_Txt_VC>APPROVED</Result_Txt_VC>" +
"<Approval_Code_CH>0943253</Approval_Code_CH>" +
"</TrxDetailCard>" +
"<TrxDetailCard>" +
"<TRX_HD_Key>18683825</TRX_HD_Key>" +
"<Date_DT>2015-10-23T21:32:00.233+00:00</Date_DT>" +
"<TRX_Card_Key>15263569</TRX_Card_Key>" +
"<Total_Amt_MN>32.0000</Total_Amt_MN>" +
"<Result_CH>0 </Result_CH>" +
"<Result_Txt_VC>APPROVED</Result_Txt_VC>" +
"<Approval_Code_CH>093389</Approval_Code_CH>" +
"</TrxDetailCard>" +
"</RichDBDS>";
XElement richDBDS = XElement.Parse(xml);
XElement results = richDBDS.Elements("TrxDetailCard").Where(x => (decimal)x.Element("Total_Amt_MN") == (decimal)32.0000).FirstOrDefault();
}
}
}
You can use Linq-to-Xml
var str = File.ReadAllText(#"C:\YourDirectory\sample.xml");
XDocument xDoc = XDocument.Parse(str);
var trxNodes = xDoc.Descendants("TrxDetailCard");
var node = trxNodes.First(n => double.Parse(n.Element("Total_Amt_MN").Value) == 32.00);