Re: [libxml++] ignore empty text nodes



On Fri, 2010-03-26 at 19:47 +0900, Andrej van der Zee wrote:
> Hi,
> 
> I am a happy user of libxmlpp for some time now. One thing I could not
> find out yet. How can I ignore empty text nodes?

By checking for them in your application when you read the XML document.
It's entirely up to your application to decide whether white space is
interesting.

>  The problem is that I
> construct a dom document by reading two XML files and merging them
> together with import_node(). I also remove some nodes manually with
> remove_child(). Finally I do a doc->write_to_stream_formatted(cout,
> "UTF-8") and end up with ugly output with holes in them like this:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <session xmlns="XXX" version="1.0" clientName="Belastingdienst"
> projectName="GBV" phase="1" iteration="1" sessionName="M2 - AUTO
> TEST3">
>   <hosts>
>     <host name="apmvsq1" cluster="apmvsp1+2" type="mainframe"
> smtEnabled="0" numCpus="666" opsys="ToBeOverwittenByParser"
> hardware="ToBeOverWrittenByParser"
> serviceLevel="ToBeOverwittenByParser" cpuSpeed="1"
> cpuSpeedBenchmark="MIPS" cacheHitPerc="95" cacheHitTime="0.0015"
> cacheMissTime="0.005" monitoringTool="ascb" timeDiff="67"/>
> 
> 
> 
> 
> 
> 
> 
>   </hosts>
> <msrs><msr xmlns=XXX" type="SU" guiName="SU1"
> ignoreEteValidator="0"><parser-logs><ete
> filename="SU1/20100304-GBV-M2-SU1.ete"/><resource
> filename="SU1/20100304-GBV-M2-SU1.mf"
> hostname="apmvsq1"/></parser-logs></msr></msrs></session>
> 
> 
> I understand that these are empty text-nodes, but I wish to ignore
> them. How can I do that without writing my own version of
> write_to_stream_formatted()? I just wish to ignore them altogether.
> 
> Thank you,
> Andrej
> 
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Libxmlplusplus-general mailing list
> Libxmlplusplus-general lists sourceforge net
> https://lists.sourceforge.net/lists/listinfo/libxmlplusplus-general


-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]