Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I am writing a XML Based Visual Studio application, whereby I need to import a simple matrix of 6 columns by 400 rows of data. The scenario is that the user puts in question number and the application looks up the question and display the 5 columns of the answer in the below format from the source data. I am having to trouble deciding how to structure the XML ?
(Note I will also have various other screen to maintain the source data file).

General Question Format to be shown on Final Screen
2.5 Autism is a lifelong developmental disability that affects how a person communicates with, and relates to,
other people. It also affects how they make sense of the world around them. (www.autism.org.uk)

2.7 Positives:
• Emergencies i.e. 999/112, GPS
• Easier to keep in touch
• Long Range communication
• Entertainment i.e. apps, camera, internet
Negatives:
• Distraction
• Cost
• Crime
• Cyber Bullying
5.18 Answer: D. All of these:
• Insurance companies can expect to pay out more in disaster claims.
• The fishing industry will suffer from low fish stocks.
• Some wine regions will no longer sustain grape crops
5.30 Answer: C: Recycling. (Recycling is the process through which waste materials are recovered and reprocessed for use in new products).

I also have an Excel table with this Table as follows :

Question No Answer Ref Answer Formatting Answer Description
2.5 Paragraph Autism is a lifelong developmental disability that affects how a person communicates with...
2.7 Paragraph Positives:
2.7 bullet Emergencies i.e. 999/112, GPS
2.7 bullet Easier to keep in touch
2.7 bullet Long Range communication
2.7 bullet Entertainment i.e. apps, camera, internet
2.7 Paragraph Negatives:
2.7 bullet Distraction
2.7 bullet Cost
2.7 bullet Crime
2.7 bullet Cyber Bullying

etc... (Not very readable with this Forum but you get the gist.

XML
XML: OPTION 1 - Flat Record
<Question_Answer_Line>
<Question No>
<Answer Ref>
<Answer Formatting>    ‘ Notice this field governs the way the screen will format the answer. i.e. buttlets
<Answer Description>
<Answer Ref Section>
<Answer Ref Colour>
<Answer Image>
<Answer Hyperlink>
</Question_Answer_Line>

XML: OPTION 2 - Master/Child Record Type Definition
<Question_Answer_MASTER_QUESTION>
<Question No>
<Answer Ref>
<Answer Description>
<Answer Ref Section>
<Answer Ref Colour>
<Answer Image>
<Answer Hyperlink>
<Question_Answer_Child>  ‘ Notice Master/Child governs the way the screen will format the answer. i.e. buttlets
<Question No>
<Answer Ref>
<Answer Description>
<Question_Answer_Child>
</Question_Answer_MASTER_QUESTION>             (or something like that).

The above XML OPTION 1 - is how I might proceed for the Schema definition but the alternative is to Master/Child type record definition… For the very experienced I would image you would make the latter option work but by putting the "Answer Formatting" tag I can control how the output should be displayed by the program.

Can anyone offer any advise ?
Thanks in advance. Kuldip.
Posted
Comments
Maciej Los 9-Jul-14 15:16pm    
Sorry, we don't get your problem...
George Jonsson 9-Jul-14 21:37pm    
I can't get it either. It is very confusing.
Can you make a real XML example of the text you describe, and not this strange XML format.
mond007 10-Jul-14 2:44am    
Ok, sorry maybe your missing some preamble. I was unable to add an image so you could visualize my screen shot.

I have already written the Visual Studio Application and works fine but I have hard-coded the questions and answers into the code. i.e the following line of code loads the data into an array is repeated several hundred times :

Call populate_array_items(1, "2.7", "-", "Positives: 0 Emergencies i.e. 999/112, GPS 0 Easier to keep in touch 0 Long Range communication 0 Entertainment i.e. apps, camera, internet Negatives: 0 Distraction 0 Cost 0 Crime 0 Cyber Bullying", "Category 2- Be Smart", "Purple", "Image 2.7", "")

Everything past the this works. The issue is that these questions keep changing and hence I have an excel file with all the data in there. It was my intention to export the data from the Excel Data file to an XML format.

Then I would load the XML Data into the array at the Form_Load point and carry on as usual. I have not got any XML file as yet this is the point at which I am stuck. i.e. How to create the XML from my Excel data File.

I was hoping to use a simple XML Schema as shown in OPTION 1 above and create an XML file and then simply read in the data into the array. If the Data changes I would replace the XML Data file and no program changes required just different Data.

Hope that makes better sense, sorry maybe I am not explaining it very well.
Thanks in Advance. Kuldip.

I recommend that you start reading up on XML structures and how to create an XSD schema.

Here is one place to start:
XML Tutorial[^]
XML Schema Tutorial[^]

As a general advice, you should never add fixed elements to a structure if you suspect the the number of elements will change.

Example of bad structuring:
XML
<parent>
    <name>Harry Hacker</name>
    <child1>Copy</child1>
    <child2>Paste</child2>
</parent>


Better structure:
XML
<parent>
    <name>Harry Hacker</name>
    <childs>
        <child id="1">Copy</child>
        <child id="2">Paste</child>
    </childs>
</parent>


Ask yourself what is the difference in the two structures when Harry gets a third kid.
What do you need to do in the first case compared to the second case?
 
Share this answer
 
v2
Hi

I managed to get a solution sorted on a different thread.

http://www.vbdotnetforums.com/xml/60658-create-effective-xml-schema-data-load-dilemma.html#post167646[^]

I have come a long way since I first posted this question.

Thanks you in advance. Regards Kuldip.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900