473,320 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

XML Novice Question

Hi I'm receiving an XML feed from one of our business partners that I
need to import into a database. I'm using XMLSpy and it really is
pretty straight forward, but I think the xml I'm receiving has unneeded
extra tags, thus I'm getting extra unneeded tables created.

Example:

<Reports>
<Report>
<Report Num>1</Report Num>
<Items>
<Item>
<Item Num>1</Item Num>
</Item>
<Item>
<Item Num>2</Item Num>
</Item>
</Items>
</Report>
</Reports>

Am I correct in thinking the "container" tags are superflous (i.e.
"Reports", "Items")? I think this is more correct:

<Report>
<Report Num>1</Report Num>
<Item>
<Item Num>1</Item Num>
<Item>
<Item Num>2</Item Num>
</Item>
</Report>

Dec 7 '06 #1
3 1134
The Gnome wrote:
Am I correct in thinking the "container" tags are superflous (i.e.
"Reports", "Items")?
That's up to whoever defined the XML-based language you're processing.
If the DTD/schema calls for them, you can't leave them out because
they're part of the structure of the document. Unlike browsers, XML
tools do not try to guess what you meant; it's up to you to say it properly.

<Reports>, or something like it, is definitely needed if a single
document may contain more than one report. An XML document *must* have a
single top-level element, so there would have to be something to contain
the multiple reports.

<Itemsmay not be strictly necessary in this case... but it really
doesn't do any harm, and it may make some kinds of processing either.

BTW, your rewritten version is broken in any case; you forgot one of the
</Itemtags. All XML elements *must* be explicitly closed.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Dec 7 '06 #2
In article <11**********************@16g2000cwy.googlegroups. com>,
"The Gnome" <jo********@gmail.comwrote:
Hi I'm receiving an XML feed from one of our business partners that I
need to import into a database. I'm using XMLSpy and it really is
pretty straight forward, but I think the xml I'm receiving has unneeded
extra tags, thus I'm getting extra unneeded tables created.

Example:

<Reports>
<Report>
<Report Num>1</Report Num>
<Items>
<Item>
<Item Num>1</Item Num>
</Item>
<Item>
<Item Num>2</Item Num>
</Item>
</Items>
</Report>
</Reports>

Am I correct in thinking the "container" tags are superflous (i.e.
"Reports", "Items")? I think this is more correct:

<Report>
<Report Num>1</Report Num>
<Item>
<Item Num>1</Item Num>
<Item>
<Item Num>2</Item Num>
</Item>
</Report>
The <Reportselement is superfluous if a single XML document can
contain only one <Reportelement. Ditto for <Items>. And the <Item>
elements would be also, unless it's likely that additional elements
would appear in each beyond the (bad) <Item Numyou show.

The above isn't legal anyway, since <Item Numis not a valid element
name (spaces aren't allowed). In addition, your second sample fails to
close one of the <Itemtags -- which is allowed (despite being poor
practice) in HTML but not XML.

= Steve =
--
Steve W. Jackson
Montgomery, Alabama
Dec 7 '06 #3
Steve W. Jackson wrote:
The above isn't legal anyway, since <Item Numis not a valid element
name (spaces aren't allowed).
Whups; hate to admit I missed that. Ditto for <Report Num>. If the
example you've shown us is really what you're receiving, you need to
have a talk with whoever is generating it and get it fixed.

Consider variants such as ItemNum or Item_Num... or just Num, since you
know from context whether it's within the scope of an Item or Report.
Or, if apporpriate, consider expressing that value as an attribute:
<Report Num="1"... </Report>


--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Dec 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Christopher Richards | last post by:
It is possible to be able to receive email alerts (say, from Google News) and publish them to a web page automatically? I am a novice as far as PHP goes, but I can open and write to a file and...
5
by: Marian | last post by:
Hi, I am totaly novice in .NET and I am studying a book about this. There was mentioned "assembly". I did not understand, how function does it has . I would like to know the exact run of code...
2
by: George | last post by:
Is this group for a novice C++ programmers?
21
by: AES/newspost | last post by:
My understanding -- I'm not an expert -- is that on (some? many? all?) standard Internet servers a URL can point to a subdirectory name followed by a backslash, and that links to this URL will...
6
by: ronwer | last post by:
Hello, The title doesn't completely cover the question I have, but it's a bit more complicated problem we have. We are using a database, based on Acces, but developed by a third party...
3
by: herrcho | last post by:
Here is the code.. #define NAME "MEGATHINK, INC" #define ADDRESS "10 Megabuck Plaza" #define PLACE "Megapolis, CA 94904" int main() { starbar(); printf("%s\n",NAME);
2
by: Dmitry Sazonov | last post by:
I'm novice here and I'm sorry for stupid question. We are trying to understand web services architecture, is it better than TIBCO.Randevouz and does webservices fit our needs. I understand, I...
1
by: Christo | last post by:
I have a question please this is just theory at the moment I am a novice java programmer Is it possible for me to write information to a hashmap and then once it has been written to extract a...
1
by: TwistedSpanner | last post by:
Hello all, For the record I am a complete java novice. I have to write a program to generate/output to screen 10 simple maths question and output a final score . The question is as follows ...
9
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.