Solved

NEWBIE: How to store boolean logic in XML?

Posted on 2007-11-21
1
1,256 Views
Last Modified: 2008-02-01
Dear Experts,

I have a dumb question.  Assume I want to store three test questions, in which BOTH of the first two are true, OR the third is true.  For instance, "If ((Birdie is blue) AND (Duckie is yellow)) OR (Bear is purple)..."

(I said this was a dumb question...)  

One way I can think of storing this would be to literally include something like parentheses and logical operators, like this:

<PAREN>
  <PAREN>
    <TEST>Birdie is blue</TEST>
    <OPERATOR>AND</OPERATOR>
    <TEST>Duckie is yellow</TEST>
  </PAREN>
</PAREN>
<OPERATOR>OR</OPERATOR>
<TEST>Bear is purple</TEST>

But there must be a better way, right?  The PARENs, in particular, seem very klutzy.  Is there a way to get their functionality directly from XML?

Thanks!
BrianMc1958
0
Comment
Question by:BrianMc1958
1 Comment
 
LVL 16

Accepted Solution

by:
McExp earned 500 total points
ID: 20329961
I would structure the XML as follows:-
<TEST Op="OR">

  <OPERAND1>

    <TEST Op="AND">

      <OPERAND1>Birdie is blue</OPERAND1>

      <OPERAND2>Duckie is yellow</OPERAND2>

    </TEST>

  </OPERAND1>

  <OPERAND2>Bear is purple</OPERAND2>

</TEST>

Open in new window

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now