[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Xerces-C 2.2.0 problem


xerces c getnodename
Hello all,

  I'm new in xerces and have one question.
  I have seen all samples but got no answer.

  The test xml file:
  
  <?xml version="1.0" encoding="windows-1251" standalone="yes"?>
  <firm id="1">
        <info>
              <title>Microsoft</title>
              <url>http://www.microsoft.com</url>
        </info>
        <pricelist>
              <pos id="1">
                   <title>windows</title>
                   <price>100$</price>
              </pos>
              ...etc...
        </pricelist>
  </firm>
  ...etc...

  i want to print all firms with they id :
  Microsoft = 1
  somefirm2 = id2
  ...etc...

  my solution:

int compareXS(char * str, const XMLCh * xml) {
        char *str1 = XMLString::transcode(xml);
        int i = strcmp(str, str1);
        XMLString::release(&str1);
        return i;
}

DOMNode* getChildByName(DOMNode *node, char *name) {
        DOMNodeList *childs = node->getChildNodes();
        for(unsigned int i=0; i<childs->getLength(); i++) {
                DOMNode *child = childs->item(i);
                if(compareXS(name,child->getNodeName())==0) {
                        return child;
                }
        }
        return NULL;
}

void showFirmList(DOMDocument *doc) {
        DOMNodeList *firms = doc->getElementsByTagName(X("firm"));
        for(unsigned int i=0;i<firms->getLength();i++) {
                DOMNode *firm = firms->item(i);
                DOMNode *info = getChildByName(firm,"info");
                DOMNode *title = getChildByName(info,"title");
                char *firm_title = XMLString::transcode(title->getNodeName());
                DOMNamedNodeMap *m = firm->getAttributes();
                DOMNode *t = m->getNamedItem(X("id"));
                char *firm_id = XMLString::transcode(t->getNodeValue());
                cerr << firm_title << " = " << firm_id << endl;
                XMLString::release(&firm_title);
                XMLString::release(&firm_id);
        }
}

  first of all that code doesn't work properly ( firm_title always point to 0x0 )
  second - using of XMLString is very uncomfortable.
  and ALL THESE CODE IS POOR i think

  what i do wrong?
  where i can get REAL samples of using xerces-c?

-- 
Best regards, Tim                          mailto:tim@s...


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.