How do I read an xml and get the result? (CAPX Included)

Get help using Construct 2

Post » Wed Nov 09, 2016 6:03 pm

Hey guys!

So, I made an excel with some cell (Item, Count). I export as xml and import in construct.
Now, I want to search for an exist item each time and when i press a button to give me the result from the cell (i want in future to have more cell).
I need also when i write a wrong item, to give me error (just a text).

Thanks very much, I really appreciate! :roll:
Last edited by odiusfly on Thu Nov 10, 2016 1:28 pm, edited 1 time in total.
B
56
S
35
G
16
Posts: 230
Reputation: 13,739

Post » Thu Nov 10, 2016 12:16 am

The XML parser doesn't like the format. This has come up before.

how-do-i-read-a-xml-and-create-a-list-with-a-preview_t181852?&hilit=excel+xml
ImageImageImage
B
71
S
22
G
257
Posts: 3,790
Reputation: 142,696

Post » Thu Nov 10, 2016 7:56 am

@blackhornet

Thank you for your answer! I saw this topic before some days, i try something without luck. Maybe i miss something.
Can you take a minute to check my capx above? We talk for 2 cell only.. Thanks! ; -)
B
56
S
35
G
16
Posts: 230
Reputation: 13,739

Post » Thu Nov 10, 2016 10:54 am

you only need this part from xml file
Code: Select all
 <Table>
   <Row>
    <Cell><Data>Item</Data></Cell>
    <Cell><Data>Count</Data></Cell>
   </Row>
   <Row>
    <Cell><Data>A</Data></Cell>
    <Cell><Data>5</Data></Cell>
   </Row>
   <Row>
    <Cell><Data>B</Data></Cell>
    <Cell><Data>10</Data></Cell>
   </Row>
   <Row>
    <Cell><Data>C</Data></Cell>
    <Cell><Data>20</Data></Cell>
   </Row>
</Table>


Image


xmlTable.capx
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Thu Nov 10, 2016 11:13 am

@korbaach

First of all big thanks for your time! I have a question.. I check your code and xml file also, you change it.. Cool but my question is: If I want to create the cell in excel then to save as xml and use the file as is in construct 2, can i? I ask because if you see xml code from excel is a bit different. Thanks again!

For example this is the code, when excel save as xml:
Code: Select all
  <Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="4" x:FullColumns="1"
   x:FullRows="1" ss:DefaultRowHeight="15">
   <Column ss:StyleID="s17" ss:Span="1"/>
   <Row>
    <Cell ss:StyleID="s16"><Data ss:Type="String">Item</Data></Cell>
    <Cell ss:StyleID="s16"><Data ss:Type="String">Count</Data></Cell>
   </Row>
   <Row>
    <Cell><Data ss:Type="String">A</Data></Cell>
    <Cell><Data ss:Type="Number">5</Data></Cell>
   </Row>
   <Row>
    <Cell><Data ss:Type="String">B</Data></Cell>
    <Cell><Data ss:Type="Number">10</Data></Cell>
   </Row>
   <Row>
    <Cell><Data ss:Type="String">C</Data></Cell>
    <Cell><Data ss:Type="Number">20</Data></Cell>
   </Row>
  </Table>


And your code:
Code: Select all
<Table>
   <Row>
    <Cell><Data>Item</Data></Cell>
    <Cell><Data>Count</Data></Cell>
   </Row>
   <Row>
    <Cell><Data>A</Data></Cell>
    <Cell><Data>5</Data></Cell>
   </Row>
   <Row>
    <Cell><Data>B</Data></Cell>
    <Cell><Data>10</Data></Cell>
   </Row>
   <Row>
    <Cell><Data>C</Data></Cell>
    <Cell><Data>20</Data></Cell>
   </Row>
</Table>
B
56
S
35
G
16
Posts: 230
Reputation: 13,739

Post » Thu Nov 10, 2016 12:50 pm

odiusfly wrote:I want to create the cell in excel then to save as xml and use the file as is in construct 2, can i?


you can..
but you need to delete some parts from xml..(which cause the error...check this capx)
you can do it manually in a text editor or C2 can do for you..


xml2Table.capx
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Thu Nov 10, 2016 1:26 pm

@korbaach
Ok Cool!!! Thanks again my friend.. ; -)
B
56
S
35
G
16
Posts: 230
Reputation: 13,739


Return to How do I....?

Who is online

Users browsing this forum: irina, purplemonkey and 8 guests