Jump to content
  • Advertisement
Sign in to follow this  
Alpha_ProgDes

Is this valid XML?

This topic is 2617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know you can have:

<name>Sam</name>

and

<name>
<nickname>Wooty</nickname>
<nickname>Yogi</nickname>
<nickname>Chi-Lite</nickname>
</name>

but is this valid/legal:

<name>Sam
<nickname>Wooty</nickname>
<nickname>Yogi</nickname>
<nickname>Chi-Lite</nickname>
</name>

Share this post


Link to post
Share on other sites
Advertisement
yes ... xml allows mixed content definitions for tags ... like this valid xhtml snippet

<div>And once he finally laid hands on <a href="daggers_of_ice.html">it</a> he felt a nearly irresistible compulsion to flee.</div>

it just isn't very desirable to do these types of formats when the focus is on data modelling / interchange vs markup.

Share this post


Link to post
Share on other sites
Just out of curiosity, what exactly are you doing with said XML?

(Just remember... XML is like violence. If it doesn't work, you just aren't using enough of it...)

Share this post


Link to post
Share on other sites
Well really this is for a FSM I'm working on.

Basically I wanted it to look like this:

<state>
<name>Assign Responsible</name>
<transition>Notify Responsible
<trigger_value>Open</trigger_value>
<trigger_value>Need Acknownledgement</trigger_value>
</transition>
<action>email</email>
</state>


Where name = state of current state, transition = name of the next state to move to, trigger_value = values needed to move to next state, action = any additional activity that must be performed while in current state.

Share this post


Link to post
Share on other sites
Personally, I'd go for something like this:

<transition target="Notify Responsible">
<trigger_value>Open</trigger_value>
<trigger_value>Need Acknownledgement</trigger_value>
</transition>

Share this post


Link to post
Share on other sites

<transition>
<target>Notify Responsible</target>
<trigger_value>Open</trigger_value>
<trigger_value>Need Acknowledgement</trigger_value>
</transition>


Is this more "acceptable" or is the difference between yours and mine a stylistic one?

Share this post


Link to post
Share on other sites
Parsing blended CDATA and tags is a bit cumbersome in most libraries I've used, if that weighs into your decision any.

Share this post


Link to post
Share on other sites


<transition>
<target>Notify Responsible</target>
<trigger_value>Open</trigger_value>
<trigger_value>Need Acknowledgement</trigger_value>
</transition>


Is this more "acceptable" or is the difference between yours and mine a stylistic one?

There's no real difference. For short, single, simple types an attribute is valid, for child nodes, long values or multiple values of the same type, sub nodes are preferable. What are your design goals ? Manual edited xml files, error robust files, easy to read, fast to read, small memory footprints ?

One tip: consider to use xml schema from the beginning to make your xml files schema conform and get some automatically xml file validation.

Share this post


Link to post
Share on other sites

Parsing blended CDATA and tags is a bit cumbersome in most libraries I've used, if that weighs into your decision any.

I'm a beginner when it comes to XML. So though I've seen CDATA tags before, they won't be showing up in this XML... ever.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!