Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

How the update the value for the second element in xml file?

$
0
0

<ABCD xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.xml.com">
    <BCDE>
        <Date></Date>
        <DCity></DCity>
        <ACity></ACity>
        <CDEF>
            <DEFG>
                <Date>2016-08-29</Date>
                <ORIG>AAA</ORIG>
                <DEST>BBB</DEST>
            </DEFG>
            <DEFG>
  <Date>2016-09-01</Date>
                <ORIG>AAA</ORIG>
                <DEST>BBB</DEST>
            </DEFG>
        </CDEF>
        <Offset>0</Offset>
        <GHFL>
            <HLJK>
                <HHHH>Adult</HHHH>
                <GGGG>0</GGGG>
            </HLJK>
        </GHFL>
        <CCDD>EEEE</CCDD>
    </BCDE>
</ABCD>

I can successfully update the Date for the first element DEFG by the following xpath.

   ht.Add("//a:ABCD/a:BCDE/a:CDEF[1]/a:DEFG/a:Date", DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"));

However I failed to update the Date for the second element DEFG by the following xpath.

   ht.Add("//a:ABCD/a:BCDE/a:CDEF[2]/a:DEFG/a:Date", DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"));

SO how to update the second element?

             


Please click the Mark as Answer button if a post solves your problem!


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>