XML tagnames & attributes


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: XML tagnames & attributes

  1. #1
    TC Guest

    XML tagnames & attributes

    Hi ALL
    How do I combine attributes & tagnames
    eg
    I have an Invoice with attributes InvoiceNumber, InvoiceDate, it has items
    with attributes itemname, & itemprice
    Using Tags I could describe this as
    <invoice>
    <invoicenumber>
    <invoicedate>
    <items>
    <item>
    <itemname>
    <itemprice>
    </item>
    </items>
    </invoice>

    How do you do this with attributes
    eg
    <invoice invoicenumber='12345' invoicedate='01/01/01' /> will describe the
    invoice but it now has no children
    This now has children
    <invoice invoicenumber='12345' invoicedate='01/01/01'
    <items>
    <item itemname='myitem' itemprice='60.00 />
    </items>
    />

    BUT causes a error with the xml parser




  2. #2
    Phil Weber Guest

    Re: XML tagnames & attributes

    > How do you do this with attributes?

    TC: Try this:

    <invoice invoicenumber='12345' invoicedate='01/01/01'>
    <items>
    <item itemname='myitem' itemprice='60.00 />
    </items>
    </invoice>

    ---
    Phil Weber



  3. #3
    Hal Guest

    Re: XML tagnames & attributes


    TC,

    The reason you are getting an error on the last XML content is because it
    is not well formed.

    It should be...

    <invoice invoicenumber='12345' invoicedate='01/01/01'>
    ...
    ...
    </invoice>

    What you did was use the coding that indicated that you had no children...when
    you actually did. Better to explain with some examples:

    This is OK
    <invoice invoicename="123"/>

    This is OK
    <invoice>
    <accountinfo accountnumber="12345"/>
    <balance current="$12.25" pastdue="$5.95"/>
    </invoice>

    This will return an error
    <invoice invoicenumber="3456">
    <balance current="$12.95"/>
    </>
    {this should be a full close tag ... </invoice>}



    "TC" <trclark@home.com> wrote:
    >Hi ALL
    >How do I combine attributes & tagnames
    >eg
    >I have an Invoice with attributes InvoiceNumber, InvoiceDate, it has items
    >with attributes itemname, & itemprice
    >Using Tags I could describe this as
    ><invoice>
    > <invoicenumber>
    > <invoicedate>
    > <items>
    > <item>
    > <itemname>
    > <itemprice>
    > </item>
    > </items>
    ></invoice>
    >
    >How do you do this with attributes
    >eg
    ><invoice invoicenumber='12345' invoicedate='01/01/01' /> will describe the
    >invoice but it now has no children
    >This now has children
    ><invoice invoicenumber='12345' invoicedate='01/01/01'
    > <items>
    > <item itemname='myitem' itemprice='60.00 />
    > </items>
    >/>
    >
    >BUT causes a error with the xml parser
    >
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center