From: Jimmy Z. <cra...@co...> - 2006-10-27 07:54:56
|
John, Can you put togehter a test case so I can test it out on my machine? Thanks, jimmy ----- Original Message ----- From: "John Kraal - Kewill Interchain NL" <jk...@in...> To: "Jimmy Zhang" <cra...@co...>; "Pieter Bas Kappel" <pk...@in...> Sent: Friday, October 27, 2006 12:22 AM Subject: Re: [Vtd-xml-users] vtdNav's getText(); > The point is, the node has text, and I suppose that it has to be found > (it's there :P) > > With a little readjustment the code looks like this: > > if (!selectXPath(ap,L"//*")) > return 1; > > bind(ap, vn); > while ((result = evalXPath(ap)) != -1) > { > elementName = toString(vn, result); > t = getText(vn); > if (t != -1) > { > elementValue = toNormalizedString(vn,t); > wprintf(L"r: %d e: %ls (%d): %ls \n", > result, > elementName, > t, > elementValue); > free(elementName); > free(elementValue); > } > count++; > } > > the XML which I created this for this purpose: > > <?xml version="1.0" encoding="UTF-8"?> > <root> > <thing attr="value"> > <subnode attr="value">Some textual data</subnode> > <anothersubnode>Some more textual data</subnode> > </thing> > <thing attr="second value"> > <subnode attr="value">even more textual data</subnode> > <anothersubnode>Even more more textual data</subnode> > </thing> > </root> > > Output: > > unims@gxvm1:~/src/xmltest$ ./test ./test.xml > size of the file is 341 bytes > > While the output with the supplied servers.xml is: > > unims@gxvm1:~/src/xmltest$ ./test servers.xml > size of the file is 7638 bytes > r: 19 e: title (20): Network World on Servers > r: 21 e: link (22): http://www.nwfusion.com/topics/servers.html > r: 23 e: description (24): The latest server news, analysis, reviews and > feature articles from Network World Fusion. > [..] > r: 212 e: description (213): Click here to see what Gartner, Network > World and other experts say about the new data center. > r: 215 e: dc:date (216): 2004-04-12T00:00:00Z > > Total number of elements 97 > > I don't actually see the problem > > Regards, > John > > Jimmy Zhang wrote: >> since VTD-XML uses integer to address a VTD record, >> in cases where the lookup returns nothing, VTDnav returns -1. >> It is equivalent to NULL in DOM... >> ----- Original Message ----- From: "John Kraal - Kewill Interchain NL" >> <jk...@in...> >> To: <vtd...@li...> >> Sent: Thursday, October 26, 2006 7:32 AM >> Subject: [Vtd-xml-users] vtdNav's getText(); >> >> >>> Hello, >>> >>> I'm busy recomposing the vtd-xml package for linux and unix with >>> autotools and strict c-compiler-thingies. It's almost working now, but >>> I've encountered this and have not yet been able to figure out why this >>> happens. >>> >>> I've got this piece of code (straight from the code sample): >>> >>> t = getText(vn); >>> wprintf(L"t: %d\n", t); >>> if (t != -1) >>> { >>> tmpString = toNormalizedString(vn,t); >>> wprintf(L" text ==> %ls \n", tmpString); >>> free(tmpString); >>> } >>> >>> Somehow getText _always_ returns -1; the file is generated by libxml2 >>> and utf-8 encoded. Could somebody please help me locate or explain this >>> problem? >>> >>> Regards, >>> >>> John Kraal >>> >>> ------------------------------------------------------------------------- >>> Using Tomcat but need to do more? Need to support web services, >>> security? >>> Get stuff done quickly with pre-integrated technology to make your job >>> easier >>> Download IBM WebSphere Application Server v.1.0.1 based on Apache >>> Geronimo >>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >>> _______________________________________________ >>> Vtd-xml-users mailing list >>> Vtd...@li... >>> https://lists.sourceforge.net/lists/listinfo/vtd-xml-users >>> >> >> > |