Note that there are some explanatory texts on larger screens.

plurals
  1. POStoring array in XML/reading it with LINQ
    primarykey
    data
    text
    <p>I am trying to get 2D array representing distances between specific cities using LINQ. It is up to me to pick proper XML representation of the problem. At first, I used MatLAB-style array to represent dependencies, which looked like this:</p> <pre><code>&lt;cityMap&gt; [-, 2, 3, 4, 5, 6, 7, 8; 1, -, 3, 4, 5, 6, 7, 8; 1, 2, -, 4, 5, 6, 7, 8; 1, 2, 3, -, 5, 6, 7, 8; 1, 2, 3, 4, -, 6, 7, 8; 1, 2, 3, 4, 5, -, 7, 8; 1, 2, 3, 4, 5, 6, -, 8; 1, 2, 3, 4, 5, 6, 7, -] &lt;/cityMap&gt; </code></pre> <p>It was very convenient to get this matrix from single LINQ query and parse it in C#, but from the XML point of view it was rather not correct (multiple data in one tag). Now I am trying something like this:</p> <pre><code>&lt;salesman&gt; &lt;salesmanNumber&gt;10&lt;/salesmanNumber&gt; &lt;cities&gt; &lt;city id="1"&gt; &lt;headquarter&gt;1&lt;/headquarter&gt; &lt;distance toCity="2"&gt;2&lt;/distance&gt; &lt;distance toCity="3"&gt;3&lt;/distance&gt; &lt;distance toCity="4"&gt;4&lt;/distance&gt; &lt;distance toCity="5"&gt;5&lt;/distance&gt; &lt;distance toCity="6"&gt;6&lt;/distance&gt; &lt;/city&gt; &lt;city id="2"&gt; &lt;headquarter&gt;1&lt;/headquarter&gt; &lt;distance toCity="1"&gt;1&lt;/distance&gt; &lt;distance toCity="3"&gt;3&lt;/distance&gt; &lt;distance toCity="4"&gt;4&lt;/distance&gt; &lt;distance toCity="5"&gt;5&lt;/distance&gt; &lt;distance toCity="6"&gt;6&lt;/distance&gt; [....] &lt;/cities&gt; &lt;/salesman&gt; </code></pre> <p>And two questions emerge: 1. Is this correct form of representing an array? 2. How to read this data with LINQ query so that I will be able to parse it to array?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload