Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How can I find the "LastModefied" value from the fallowing xml with out looping.

XML
<BucketItem xmlns="http://schemas.datacontract.org/2004/07/Schakra.OneAWS.S3.Core.Resources.File" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <ContentType>binary/octet-stream</ContentType>
  <ETag>etag</ETag>
  <LastModified>Tue, 08 Apr 2014 11:50:53 GMT</LastModified>
  <Metadata xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <a:KeyValueOfstringstring>
      <a:Key>hello</a:Key>
      <a:Value>1</a:Value>
    </a:KeyValueOfstringstring>
    <a:KeyValueOfstringstring>
      <a:Key>hi</a:Key>
      <a:Value>4</a:Value>
    </a:KeyValueOfstringstring>
  </Metadata>
  <Owner xmlns:a="http://schemas.datacontract.org/2004/07/Schakra.OneAWS.S3.Core.Resources">
    <a:_x003C_DisplayName_x003E_k__BackingField>owner1</a:_x003C_DisplayName_x003E_k__BackingField>
    <a:_x003C_ID_x003E_k__BackingField>12345</a:_x003C_ID_x003E_k__BackingField>
  </Owner>
  <Size>444</Size>
</BucketItem>



thanks
purna
Posted

Use the XmlDocument Class[^].
 
Share this answer
 
Comments
Purna.N 8-Apr-14 4:43am    
I don't want to use the xmlnode. After loading of the xml file then I need to get the value of the specified node.
Richard MacCutchan 8-Apr-14 5:01am    
You could use XmlReader or write your own.
If we are using this we don't want loop the xml nodes.

XML
XmlDocument xmldocinner = new XmlDocument();
            xmldocinner.Load(MetaDataRepository + "/" + metadataMappedKey);
<pre lang="cs">var root = xmldocinner.GetElementsByTagName(&quot;LastModified&quot;);
var lastmodifieddate = root[0].InnerText;</pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900