Xml

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • outofmymind
    New Member
    • Oct 2006
    • 45

    Xml

    Hey,

    I came across this question, this is the 1st time I write a XML file, and I have no idea if my work is correct, or if thats how its supposed to be.......please give me your feedback:

    Consider the following XML file that describes a pizza:
    An order for a Pizza in a restaurant, stores the name, address, and the phone number of the customer. It stores also the description of one or more pizzas. A pizza has a size (small priced at $10, medium at $13 and large at $16), a crust type (thin or thick) and one or more toppings. The toping could be meat (beef or chicken), vegetable (red onion or cilantro).

    Create an XML file that describes two different order for two different pizza.


    this is what i did:

    Code:
    <?xml version = ”1.0” ?>
    <Pizza>
    <name> My Pizza </name>
    <address> Kitchen </address>
    <phoneNumber> 065432198 </phoneNumber>
    <description> 
    <size> small </size>
    <price> $10 </price>
    <crust> thin </crust>
    <topping>
    <meat>beef </meat>
    <meat>chicken</meat>
    <vegetable> red onion </vegetable>
    <vegetable> cilantro </vegetable>
    </topping>
    </description>
    <name> His Pizza </name>
    <address> Kitchen2 </address>
    <phoneNumber> 0625678800 </phoneNumber>
    <description> 
    <size> large </size>
    <price> $16 </price>
    <crust> thick </price>
    <topping>
    <meat>beef </meat>
    <meat>chicken<meat>
    <vegetable> red onion </vegetable>
    <vegetable> cilantro </vegetable>
    </topping>
    </description>
    </Pizza>
    Thanks in advance....
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by outofmymind
    Hey,

    I came across this question, this is the 1st time I write a XML file, and I have no idea if my work is correct, or if thats how its supposed to be.......please give me your feedback:

    Consider the following XML file that describes a pizza:
    An order for a Pizza in a restaurant, stores the name, address, and the phone number of the customer. It stores also the description of one or more pizzas. A pizza has a size (small priced at $10, medium at $13 and large at $16), a crust type (thin or thick) and one or more toppings. The toping could be meat (beef or chicken), vegetable (red onion or cilantro).

    Create an XML file that describes two different order for two different pizza.


    this is what i did:

    Code:
    <?xml version = ”1.0” ?>
    <Pizza>
    <name> My Pizza </name>
    <address> Kitchen </address>
    <phoneNumber> 065432198 </phoneNumber>
    <description> 
    <size> small </size>
    <price> $10 </price>
    <crust> thin </crust>
    <topping>
    <meat>beef </meat>
    <meat>chicken</meat>
    <vegetable> red onion </vegetable>
    <vegetable> cilantro </vegetable>
    </topping>
    </description>
    <name> His Pizza </name>
    <address> Kitchen2 </address>
    <phoneNumber> 0625678800 </phoneNumber>
    <description> 
    <size> large </size>
    <price> $16 </price>
    <crust> thick </price>
    <topping>
    <meat>beef </meat>
    <meat>chicken<meat>
    <vegetable> red onion </vegetable>
    <vegetable> cilantro </vegetable>
    </topping>
    </description>
    </Pizza>
    Thanks in advance....
    Strictly speaking this should have been posted in the XML forum. The little xml knowledge I have says that maybe you can structure this in many ways. However the following seem to be required for this design

    [PHP] <order>
    <pizza>
    .....
    </pizza>
    <pizza>
    .....
    </pizza>
    </order>
    <order>
    <pizza>
    .....
    </pizza>
    <pizza>
    .....
    </pizza>
    </order>
    [/PHP]

    To represent two different orders of two different pizzas. Also name address and phone should not go under pizza but under customer so you'd have

    [PHP] <order>
    <customer>
    <name>
    .....
    </name>
    .....
    </customer>
    <pizza>
    .....
    </pizza>
    <pizza>
    .....
    </pizza>
    </order>
    [/PHP]
    i.e each order is made by a customer with a name, address etc.
    Remember however that your xml must have one root
    Maybe something like
    <order-form>
    <order>
    ...
    </order>
    </order-form>

    Comment

    • outofmymind
      New Member
      • Oct 2006
      • 45

      #3
      Originally posted by r035198x
      Strictly speaking this should have been posted in the XML forum. The little xml knowledge I have says that maybe you can structure this in many ways. However the following seem to be required for this design

      [PHP] <order>
      <pizza>
      .....
      </pizza>
      <pizza>
      .....
      </pizza>
      </order>
      <order>
      <pizza>
      .....
      </pizza>
      <pizza>
      .....
      </pizza>
      </order>
      [/PHP]

      To represent two different orders of two different pizzas. Also name address and phone should not go under pizza but under customer so you'd have

      [PHP] <order>
      <customer>
      <name>
      .....
      </name>
      .....
      </customer>
      <pizza>
      .....
      </pizza>
      <pizza>
      .....
      </pizza>
      </order>
      [/PHP]
      i.e each order is made by a customer with a name, address etc.
      Remember however that your xml must have one root
      Maybe something like
      <order-form>
      <order>
      ...
      </order>
      </order-form>
      Ohhh ok thanks i'l work on it and post it in the XML forum, i just thought that since this was part of the java course that im doing i should post it here........tha nks alot anyway,

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by outofmymind
        Ohhh ok thanks i'l work on it and post it in the XML forum, i just thought that since this was part of the java course that im doing i should post it here........tha nks alot anyway,
        Not a big problem though. You don't have to post it in the XML forum then. I'll copy it over there for you so people in the XML forum can contribute and while you are posting here in the java forum.

        Comment

        • outofmymind
          New Member
          • Oct 2006
          • 45

          #5
          Originally posted by r035198x
          Not a big problem though. You don't have to post it in the XML forum then. I'll copy it over there for you so people in the XML forum can contribute and while you are posting here in the java forum.

          Hi,

          Thanks for your help!! :)

          Is this good?? Or do I have it all stuffed up?? :(

          [PHP]<?xml version = ”1.0” ?>
          <Order>
          <Pizza>
          <Customer>
          <name> My Pizza </name>
          <address> Kitchen </address>
          <phoneNumber> 065432198 </phoneNumber>
          </Customer>
          <description>
          <size> small </size>
          <price> $10 </price>
          <crust> thin </crust>
          <topping>
          <meat>beef </meat>
          <meat>chicken </meat>
          <vegetable> red onion </vegetable>
          <vegetable> cilantro </vegetable>
          </topping>
          </description>
          </Pizza>
          </Order>

          <Order>
          <Pizza>
          <Customer>
          <name> His Pizza </name>
          <address> Kitchen2 </address>
          <phoneNumber> 0625678800 </phoneNumber>
          </Customer>
          <description>
          <size> large </size>
          <price> $16 </price>
          <crust> thick </price>
          <topping>
          <meat>beef </meat>
          <meat>chicken<m eat>
          <vegetable> red onion </vegetable>
          <vegetable> cilantro </vegetable>
          </topping>
          </description>
          </Pizza>
          </Order>[/PHP]

          Thanks again :)

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            [PHP]<?xml version="1.0" encoding="UTF-8"?>
            <Order-sheet>
            <Order>
            <Customer>
            <name> Sherlock Holmes </name>
            <address> 10 Baker Street </address>
            <phoneNumber> 065432198 </phoneNumber>
            </Customer>
            <Pizza>
            <size> small </size>
            <price> $10 </price>
            <crust-type> thin </crust-type>
            <topping type="meat">
            Beef
            </topping>
            </Pizza>
            </Order>
            <Order>
            <Customer>
            <name> Dr Watson </name>
            <address> 10 Baker Street </address>
            <phoneNumber> 065432198 </phoneNumber>
            </Customer>
            <Pizza>
            <size> medium </size>
            <price> $13 </price>
            <crust-type> thick </crust-type>
            <topping type="vegetable ">
            cilantro
            </topping>
            </Pizza>
            </Order>
            </Order-sheet>[/PHP]


            I think it should be along these lines. Note that if you have internet explorer you can open the xml using explorer and if there are any errors in your xml explorer will tell you.

            Comment

            • outofmymind
              New Member
              • Oct 2006
              • 45

              #7
              Originally posted by r035198x
              [PHP]<?xml version="1.0" encoding="UTF-8"?>
              <Order-sheet>
              <Order>
              <Customer>
              <name> Sherlock Holmes </name>
              <address> 10 Baker Street </address>
              <phoneNumber> 065432198 </phoneNumber>
              </Customer>
              <Pizza>
              <size> small </size>
              <price> $10 </price>
              <crust-type> thin </crust-type>
              <topping type="meat">
              Beef
              </topping>
              </Pizza>
              </Order>
              <Order>
              <Customer>
              <name> Dr Watson </name>
              <address> 10 Baker Street </address>
              <phoneNumber> 065432198 </phoneNumber>
              </Customer>
              <Pizza>
              <size> medium </size>
              <price> $13 </price>
              <crust-type> thick </crust-type>
              <topping type="vegetable ">
              cilantro
              </topping>
              </Pizza>
              </Order>
              </Order-sheet>[/PHP]


              I think it should be along these lines. Note that if you have internet explorer you can open the xml using explorer and if there are any errors in your xml explorer will tell you.
              Thanks!! how can i open my xml with internet explorer......i s it a long process?
              thanks again!

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #8
                Originally posted by outofmymind
                Thanks!! how can i open my xml with internet explorer......i s it a long process?
                thanks again!
                Not at all just right-click the file select Open with and choose Program from the menus then just choose internet explorer.

                Comment

                Working...