XElement modify element and get element value

  • Thread starter Thread starter CY_Chen
  • Start date Start date
C

CY_Chen

Guest
I try to get XElement item value and set value

Below is my structure


<CONFIG xmlns:xdi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="XML Schema" FrameWidth="400" FrameHeight="200">

<Frames>
<FRAME FrameName="Frame0">
<Frame_Elements>
<Frame_Element><!--Frame_Element[0]-->
<Basic><!--Basic[0]-->
<Id>0</Id>
<Uid>0</Uid>
</Basic>
<Base><!--Base[0]-->
<BaseFilePath>C:/Image</BaseFilePath>
<BaseFileName>f.png</BaseFileName>
</Base>
</Frame_Element>
<Frame_Element><!--Frame_Element[1]-->
<Basic><!--Basic[1]-->
<Id>1</Id>
<Uid>0</Uid>
</Basic>
<Base><!--Base[1]-->
<BaseFilePath>C:/Image</BaseFilePath>
<BaseFileName>large.png</BaseFileName>
</Base>
</Frame_Element>
<Frame_Element><!--Frame_Element[2]-->
<Basic><!--Basic[2]-->
<Id>2</Id>
<Uid>0</Uid>
</Basic>
<Base><!--Base[2]-->
<BaseFilePath>C:/Image</BaseFilePath>
<BaseFileName>medium.png</BaseFileName>
</Base>
</Frame_Element>
<Frame_Element><!--Frame_Element[0]-->
<Basic><!--Basic[3]-->
<Id>3</Id>
<Uid>0</Uid>
</Basic>
<Base><!--Base[3]-->
<BaseFilePath>C:/Image</BaseFilePath>
<BaseFileName>small.png</BaseFileName>
</Base>
</Frame_Element>
</Frame_Elements>
</FRAME>
<FRAME FrameName="Frame1">
<Frame_Elements>
<Frame_Element><!--Frame_Element[4]-->
<Basic><!--Basic[4]-->
<Id>4</Id>
<Uid>0</Uid>
</Basic>
<Base><!--Base[4]-->
<BaseFilePath>C:/Image</BaseFilePath>
<BaseFileName>Main.png</BaseFileName>
</Base>
</Frame_Element>
<Frame_Element><!--Frame_Element[5]-->
<Basic><!--Basic[5]-->
<Id>5</Id>
<Uid>0</Uid>
</Basic>
<Base><!--Base[5]-->
<BaseFilePath>C:/Image</BaseFilePath>
<BaseFileName>icon.png</BaseFileName>
</Base>
</Frame_Element>
</Frame_Elements>
</FRAME>


If I want to get <Id>5

<Frame_Element><!--Frame_Element[5]-->
<Basic><!--Basic[5]-->
<Id>5</Id>

How to get Id value

And If I want to modify FrameWidth to 100

And modify any <Basic> or <Base> item .

How to do those?

Thanks

Continue reading...
 
Back
Top