書き込み
Dim i As Integer i = 1 Dim xml = XDocument.Load(savedXmlFileName) For Each op In outputPictList Dim str1 = xml.Descendants("Objects").FirstOrDefault() str1.Add(New XElement("Pict")) Dim str2 = xml.Descendants("Pict").LastOrDefault str2.Add(New XElement("pictNum", pictList(i, 0))) str2.Add(New XElement("indexNum", pictList(i, 1))) str2.Add(New XElement("viewFileName", pictList(i, 2))) str2.Add(New XElement("fileFullPath", pictList(i, 3))) str2.Add(New XElement("rotateDegree", pictList(i, 4))) str2.Add(New XElement("statusOfMarker", pictList(i, 5))) str2.Add(New XElement("pictTitle", pictList(i, 6))) xml.Save(savedXmlFileName) i = i + 1 Next
読み込み
Dim doc1 = XDocument.Load(savedXmlFileName) Dim query1 = From c In doc1.Descendants("Pict") Where c.Element("fileFullPath") IsNot Nothing Dim i As Integer i = 1 For Each c In query1 pictList(pictNum, 0) = pictNum pictList(pictNum, 1) = c.Element("indexNum").Value pictList(pictNum, 2) = c.Element("viewFileName").Value pictList(pictNum, 3) = c.Element("fileFullPath").Value pictList(pictNum, 4) = c.Element("rotateDegree").Value pictList(pictNum, 5) = c.Element("statusOfMarker").Value pictList(pictNum, 6) = c.Element("pictTitle").Value CheckedListBox1.Items.Add(pictNum & " : " & c.Element("viewFileName").Value) i = i + 1 pictNum = pictNum + 1 Next
XMLファイル
<?xml version="1.0" encoding="utf-8"?> <Objects> <Pict> <pictNum>1</pictNum> <indexNum>1</indexNum> <viewFileName>Chrysanthemum.jpg</viewFileName> <fileFullPath>C:\Users\username\Desktop\pict\Chrysanthemum.jpg</fileFullPath> <rotateDegree>0</rotateDegree> <statusOfMarker>0</statusOfMarker> <pictTitle>pict1</pictTitle> </Pict> <Pict> <pictNum>2</pictNum> <indexNum>2</indexNum> <viewFileName>Desert.jpg</viewFileName> <fileFullPath>C:\Users\username\Desktop\pict\Desert.jpg</fileFullPath> <rotateDegree>0</rotateDegree> <statusOfMarker>0</statusOfMarker> <pictTitle>pict2</pictTitle> </Pict> <Pict> <pictNum>3</pictNum> <indexNum>3</indexNum> <viewFileName>Hydrangeas.jpg</viewFileName> <fileFullPath>C:\Users\username\Desktop\pict\Hydrangeas.jpg</fileFullPath> <rotateDegree>0</rotateDegree> <statusOfMarker>0</statusOfMarker> <pictTitle>pict3</pictTitle> </Pict> <Pict> <pictNum>4</pictNum> <indexNum>4</indexNum> <viewFileName>Jellyfish.jpg</viewFileName> <fileFullPath>C:\Users\username\Desktop\pict\Jellyfish.jpg</fileFullPath> <rotateDegree>0</rotateDegree> <statusOfMarker>0</statusOfMarker> <pictTitle>pict4</pictTitle> </Pict> <Pict> <pictNum>5</pictNum> <indexNum>5</indexNum> <viewFileName>Koala.jpg</viewFileName> <fileFullPath>C:\Users\username\Desktop\pict\Koala.jpg</fileFullPath> <rotateDegree>0</rotateDegree> <statusOfMarker>0</statusOfMarker> <pictTitle>pict5</pictTitle> </Pict> <Pict> <pictNum>6</pictNum> <indexNum>6</indexNum> <viewFileName>Lighthouse.jpg</viewFileName> <fileFullPath>C:\Users\username\Desktop\pict\Lighthouse.jpg</fileFullPath> <rotateDegree>0</rotateDegree> <statusOfMarker>0</statusOfMarker> <pictTitle>pict6</pictTitle> </Pict> <Pict> <pictNum>7</pictNum> <indexNum>7</indexNum> <viewFileName>Penguins.jpg</viewFileName> <fileFullPath>C:\Users\username\Desktop\pict\Penguins.jpg</fileFullPath> <rotateDegree>0</rotateDegree> <statusOfMarker>0</statusOfMarker> <pictTitle>pict7</pictTitle> </Pict> <Pict> <pictNum>8</pictNum> <indexNum>8</indexNum> <viewFileName>Tulips.jpg</viewFileName> <fileFullPath>C:\Users\username\Desktop\pict\Tulips.jpg</fileFullPath> <rotateDegree>0</rotateDegree> <statusOfMarker>0</statusOfMarker> <pictTitle>pict8</pictTitle> </Pict> </Objects>
0 件のコメント:
コメントを投稿