Click to See Complete Forum and Search --> : XML tagnames & attributes


TC
03-21-2000, 10:59 PM
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

Phil Weber
03-21-2000, 11:45 PM
> 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

Hal
03-22-2000, 09:00 AM
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
>
>
>