-
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
-
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
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks