none
Load and Save OpenXml RRS feed

  • Question

  • I try to save my structure into xml

    like below code

    <?xml version="1.0" encoding="UTF-8"?>
    
    -<CONFIG xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <AIndex>2</AIndex>
    
    <BIndex>1</BIndex>
    
    <CIndex>8</CIndex>
    
    <DIndex>0</DIndex>
    
    -<Frames>
    
    -<FRAME FrameName="Frame 0">
    
    -<Frame_Elements>
    
    
    <BaseFilePath>C:\1\Image</BaseFilePath>
    
    <BaseFileName>SO_BIG.jpg</BaseFileName>
    
    <BaseCX>283</BaseCX>
    
    <BaseCY>218</BaseCY>
    
    
    
    <BaseFilePath>C:\1\Image</BaseFilePath>
    
    <BaseFileName>SO_HAPPY.jpg</BaseFileName>
    
    <BaseCX>52</BaseCX>
    
    <BaseCY>13</BaseCY>
    
    
    <BaseFilePath>C:\1\Image</BaseFilePath>
    
    <BaseFileName>45.jpg</BaseFileName>
    
    
    <BaseX>0</BaseCX>
    
    <BaseY>0</BaseCY>
    
    
    </Frame_Elements>
    
    </FRAME>
    
    -<FRAME FrameName="Frame 1">
    
    -<Frame_Elements>
    
    
    
    <BaseFilePath>C:\1\Image</BaseFilePath>
    
    <BaseFileName>SO_SAD.jpg</BaseFileName>
    
    <BaseCX>152</BaseCX>
    
    <BaseCY>113</BaseCY>
    
    
    
    
    </Frame_Elements>
    
    </FRAME>
    </Frames>
    
    </CONFIG>

    My structure was TabControl contain TabIitem[0] TabItem[1]

    TabItem[0] contain Canvas ,Canvas contain three images (SO_BIG.jpg--location (283,218))/(SO_HAPPY.jpg--location (52,13))/(45.jpg--location(0,0))

    TabItem[1] contain Canvas ,Canvas contain one image (SO_SAD.jpg--location(152,113))

    I wan to load my  structure into List<string> configList

    My configLstwill may look like

    configList.Add("<?xml version="1.0" encoding="UTF-8"?>");
    configList.Add("-<CONFIG xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">");
    configList.Add("<AIndex>2</AIndex>");
    configList.Add("<BIndex>2</BIndex>");

    But it may not work well to load my structure

    And I also got problem on how to load xml then my TabControl will know how many TabItem it have.

    And each TabItem will know how many images it have and  set image on canvas location?

    I got problem on How to save xml and load xml then set image on each TabItem own canvas.

    Thanks 


    Tuesday, September 17, 2019 2:34 AM

All replies


  • Hi    CY_Chen,

    You need to define your own xml format and save information to related note. Then, you can read the information according to the structure level and generate TabItem and canvas and so on dynamically.

    The following links for your reference.

    Reading and Writing XML in C#/VB.Net
    https://www.codeproject.com/Articles/1222133/Reading-and-Writing-XML-in-Csharp-VB-Net



    Best regards

    Yong Lu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, September 17, 2019 8:07 AM
    Moderator