Bonjour à tous,
J’essaie de faire un petit programme qui récupère certaines valeurs dans un fichier xml. Ces données je veux les mettre dans un tableau nommé Tbl_Patch
voici une partie du fichier xml:
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="styles/fixture+layer+layers@html@default.xsl"?> <?xml-stylesheet type="text/xsl" href="styles/fixture+layer+layers@csv.xsl" alternate="yes"?> <MA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.malighting.de/grandma2/xml/MA" xsi:schemaLocation="http://schemas.malighting.de/grandma2/xml/MA http://schemas.malighting.de/grandma2/xml/3.6.1/MA.xsd" major_vers="3" minor_vers="6" stream_vers="1"> <Info datetime="2019-04-01T09:20:42" showfile="macbeth-test" /> <Layers index="3"> <Layer index="1" name="gradateurs"> <Fixture index="0" name="Dim 68" fixture_id="68" channel_id="68"> <FixtureType name="2 Dimmer 00"> <No>2</No> </FixtureType> <SubFixture index="0" react_to_grandmaster="true" color="ffffff"> <Patch> <Address>143</Address> </Patch> <AbsolutePosition> <Location x="0" y="0" z="0" /> <Rotation x="0" y="-0" z="0" /> <Scaling x="1" y="1" z="1" /> </AbsolutePosition> <Channel index="0" /> </SubFixture> </Fixture>
et voici ce que j'ai codé:
j'arrive à récupérer Tbl_Patch(u,0) et Tbl_Patch(u,2) mais pas Tbl_Patch(u,1) qui doit être <Fixture><fixturetype><name>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 Dim cpo_patch As XDocument = XDocument.Load(Lbl_patch.Text) Dim popatch As XElement = cpo_patch.Root.<Layers>.FirstOrDefault Dim listPatch As IEnumerable(Of XElement) = popatch.Elements() For Each listfixture In listPatch If listfixture.HasElements Then Dim Fixtures As IEnumerable(Of XElement) = listfixture.Elements Dim u As Integer = 0 For Each fixture In Fixtures If fixture.HasElements Then Tbl_Patch(u, 0) = fixture.@<channel_id> Tbl_Patch(u, 1) = fixture.<fixturetype>.@<name> Tbl_Patch(u, 2) = fixture.@<name> MsgBox(Tbl_Patch(u, 0) & " / " & Tbl_Patch(u, 1) & " / " & Tbl_Patch(u, 2)) End If Next End If Next
Qu'est ce que je n'ai pas bien fait ?
D'avance merci.
Partager