I've been working with this stuff for hte first time over the past month,
and I just had to chug through it by studying the examples that come with
the source code and reading the Xerces C++ documentation.  The test programs
were also good to look at.

Anyway, here's how I would approach your problem:

-----
I want to extract the tag "person id" and its value "Big.Boss".  
Then the tag "email" and its value "[EMAIL PROTECTED]".  
Then the tag "link subordinates" and its value "one.worker two.worker
three.worker four.worker five.worker"  etc......

Any help is greatly appreciated.

The first record in the file reads like this:
- <person id="Big.Boss"> 
 <name> 
<family>Boss</family> 
<given>Big</given> 
</name> 
<email>[EMAIL PROTECTED]</email> 
<link subordinates="one.worker two.worker three.worker four.worker
five.worker" /> 
</person>
-----

I'm guessing your database has many person records in it.

// Assume myDocument is a DOMDocument that is returned by a parse operation

DOMNodeList* personList = myDocument->getElementsByTagName("person");

for (i=0; i<personList->getLength(); i++) {
  printf("person id = %s\n", personList->item(i)->getAttribute("id"));
  DOMElement* email =
personList->item(i)->getElementsByTagName("email")->item(0);
  printf("email = %s\n", email->getFirstChild()->getNodeValue());
  DOMElement* link =
personList->item(i)->getElementsByTagName("link")->item(0);
  char* linkString = link->getAttribute("subordinates");
  // tokenize the linkString to get the subordinates
}

This code is sort of C-ish and I skipped the transcode steps, but it should
give you an idea.

Like many problems, there are a lot of solutions - this is just one from a
non-expert.

Hope this helps,
Karl

> -----Original Message-----
> From: Purdy, Edgar M [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 23, 2003 7:23 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Tutorials
> 
> 
> Can someone recommend URL's for XML tutorials that apply to c++.
> Functionality eluded to in the Java tutorials is not available in c++.
> In Java the properties class is utilized, no such class exists in c++
> and my efforts to create my own c++ equivalent of the Java properties
> class has not been successful.
> 
> Ed Purdy
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to