Altova Mailing List Archives


Re: Sub-elements of a given element and proper XML formatting

From: William Park <opengeometry@-----.-->
To: NULL
Date: 9/20/2004 5:05:00 AM
Brad M. <anonymous@d...> wrote:
> Hi.  I'm new to XML, and have just downloaded the documentation, but I'm
> still stuck on a problem I'm having.  Below is XML file:
> 
> <?xml version="1.0"?>
> <JobHeader>
> <JobProperties>
> <JobNumber>240</JobNumber>
> <JobStartDate>2004-09-16</JobStartDate>
> <ClientName>Client 1</ClientName>
> <PackageNumber>502</PackageNumber>
> <Province>ONT</Province>
> <Location>Location 1</Location>
> <SupervisorName>Supervisor</SupervisorName>
> <SupervisorTel>(212) 555-1212</SupervisorTel>
> <JobDescription>Job Description Here</JobDescription>
> <TestFile>File Path Here</TestFile>
> <CustomerNotes>Notes here, if any</CustomerNotes>
> </JobProperties>
> <JobContacts>
> <Contact>
> <ContactName>Person 1</ContactName>
> <ContactFax>(212) 555-1212</ContactFax>
> <ContactEmail>email@d...</ContactEmail>
> </Contact>
> <Contact>
> <ContactName>Person 2</ContactName>
> <ContactFax>(212) 555-1212</ContactFax>
> <ContactEmail>email@d...</ContactEmail>
> </Contact>
> <Contact>
> <ContactName>Person 3</ContactName>
> <ContactFax>(212) 555-1212</ContactFax>
> <ContactEmail>email@d...</ContactEmail>
> </Contact>
> <Contact>
> <ContactName>Person 4</ContactName>
> <ContactFax>(212) 555-1212</ContactFax>
> <ContactEmail>email@d...</ContactEmail>
> </Contact>
> <Contact>
> <ContactName>Person 5</ContactName>
> <ContactFax>(212) 555-1212</ContactFax>
> <ContactEmail>email@d...</ContactEmail>
> </Contact>
> <Contact>
> <ContactName>Person 6</ContactName>
> <ContactFax>(212) 555-1212</ContactFax>
> <ContactEmail>email@d...</ContactEmail>
> </Contact>
> <Contact>
> <ContactName>Person 7</ContactName>
> <ContactFax>(212) 555-1212</ContactFax>
> <ContactEmail>email@d...</ContactEmail>
> </Contact>
> <Contact>
> <ContactName>Person 8</ContactName>
> <ContactFax>(212) 555-1212</ContactFax>
> <ContactEmail>email@d...</ContactEmail>
> </Contact>
> </JobContacts>
> </JobHeader>
> 
> Now, I have a need to parse through this file.  I can do so with the
> JobProperties section, but I am having trouble with the JobContacts
> section.  I need to loop through and grab each Contact element, and
> populate a grid with it's sub-elements.  Then go to the next Contact
> element, and so on and so forth.  There can be an unlimited number of
> contacts.  I am using VB to accomplish this.

I know Bash shell solution.  It requires you to patch/compile Bash-3.0,
unfortunately.

> Also, one more question
> - in a situation like this, should I be using Contact1, Contact2,
> Contact3, etc??  Or is the method I am currently employing fine?

You could put each in a single element using attributes, eg.
    <Contact name="Person 1" fax="(212) 555-1212" email="email@d..."/>
Then, you could include this under <JobProperties> along with other job
infos.  Perhaps, eliminating <JobProperties> altogether, because
<JobHeader> would suffice, then.

> If any more information is required, please let me know.  Any help in
> this matter will be greatly appreciated!

-- 
William Park <opengeometry@y...>
Open Geometry Consulting, Toronto, Canada

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.