Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Which is the better way of representing in XML?

Posted on 2008-11-11
8
Medium Priority
?
161 Views
Last Modified: 2012-05-05
Hi
I have kept all the messages of my application in a XML like this.

<Module id ="1" name ="FileProcess">
    <Message id ="1">Started processing the input file...</Message>
    <Message id ="2">Stopped processing the input file</Message>
    <Message id ="3">Input File is Valid</Message>
  </Module>

But, what is the difference between the above and the below. In the above one I kept the message in between the tags. Below, I kept the messge as an attribute. So which is better way?

 <Module id ="1" name ="FileProcess">
    <Message id ="1" msg ="Started processing the input file..." />
    <Message id ="2" msg ="Stopped processing the input file" />
    <Message id ="3" msg = "Input File is Valid" />
 </Module>

Which is better and why?
Can anyone explain me clearly?
0
Comment
Question by:GouthamAnand
  • 4
  • 4
8 Comments
 
LVL 3

Expert Comment

by:SreejithG
ID: 22937070
Second one is better. Reason : - The message can be of multi line. Attribute value doesnot support multi line string. Also can have some chars that a attribute value doesnot support.
0
 

Author Comment

by:GouthamAnand
ID: 22937755
Why the second one is better, when you are saying that it does not support 'multiline string' and special charecters ?
0
 

Author Comment

by:GouthamAnand
ID: 22937763
Which are the charecters that it does not support , if I choose the second option.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:SreejithG
ID: 22937880
Opps, sorry
First one is better
0
 
LVL 3

Expert Comment

by:SreejithG
ID: 22937894
OK I will put in another way. You can have CDATA node under the Node and have any chars. But in attribute value you need to escape these .
0
 

Author Comment

by:GouthamAnand
ID: 22938025
Can you give me an example for this.
0
 
LVL 3

Accepted Solution

by:
SreejithG earned 2000 total points
ID: 22938077
here it is
<Module id ="1" name ="FileProcess">
    <Message id ="1">Started processing the input file...in < 10 sec</Message>
    <Message id ="2">Stopped processing the input file</Message>
    <Message id ="3">Input File is Valid</Message>
  </Module>
Above XML is invalid. You can make it valid as below or by escaping the <  to &lt;
<Module id ="1" name ="FileProcess">
    <Message id ="1"><![CDATA[ Started processing the input file...in < 10 sec ]]></Message>
    <Message id ="2">Stopped processing the input file</Message>
    <Message id ="3">Input File is Valid</Message>
  </Module>

Open in new window

0
 

Author Closing Comment

by:GouthamAnand
ID: 31515852
Thank you.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video teaches viewers about errors in exception handling.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question