c++ - TinyXML Element extraction as text -


I'm trying to create an XML signature system I have my XML might be something like below:

  & lt; Main & gt; & Lt; ChildType1 & gt; ... & lt; / ChildType1 & gt; & Lt; ChildType2 & gt; ... & lt; / ChildType2 & gt; & Lt; / Home & gt; In reality, it will be agnostic on the type of data under the  main  node. And I only want to calculate CRC data in  main  node and  signature  on  main .  

P> But I just wrote

  ostringstream ss; (Boost :: archive :: text_oarchive oa (ss); ss.str ( ""); try {TiXmlBase :: SetCondenseWhiteSpace (false); Tinyxml :: Document; doc.LoadFile (filename.c_str ()); Tinyxml: : element * scheme = tinyxml :: findSingleElement & lt; SchemesSignatureException & gt; (doctor, "Men"); if (plans == 0) Logika_arer ( "No key found") throw; tinyxml :: TinyXmlFwdIterator & LT; tinyxml :: Elements> Children; (Children = Children. Bijin (plans); Children! = Child.end (); ++ child) {// Question is here, How to get an XML lesson of each child in Men. .}} (Exception and A) {Throw;}} String Data (Ss.str ()); boost :: Siarsi_32_taip CRC; Crc.process_bytes (data.data (), data.size ());   

I iterate over child as I can get how XML text string, for my example, the first walk in "..." oa will flush and oa second line "..." ?

I tried GetText, but it always comes back empty! Do you have an idea?

In the end I have found that the overload is & lt; & Lt; operator and recurring treat all node dumped into an output stream with the one right choice, so I use the following code to drill down in the node and format what I want. I've lost all angle-bracket signals, but it's okay for me.

  std :: ostream & amp; Operator & lt; & Lt; (Std :: ostream & out, tinyxml :: node * pParent) {naming place tinyxml; If (! PPIR) returns back; TiXmlText * pText; Ticsual Attributes * Petrib; Int t = pParent- & gt; type (); Switch (T) {Case TiXmlNode :: TINYXML_DOCUMENT: Break; Case TiXmlNode :: TINYXML_ELEMENT: Out & lt; & Lt; Parent- & gt; value (); Patrib = ((TinyXML :: Element *) (PPP)) - & gt; First Attitude (); While (Petrib) {out & lt; & Lt; Bar-> Name () & lt; & Lt; PAttrib-> value (); Patreb = bar-> next (); } Case TiXmlNode :: TINYXML_COMMENT: Break; Case TiXmlNode :: TINYXML_UNKNOWN: Break; Case TiXmlNode :: TINYXML_TEXT: pText = pParent- & gt; ToText (); Outside & lt; & Lt; PText-> value (); break; Case TiXmlNode :: TINYXML_DECLARATION: Break; Default: Break; } / * Out & lt; & Lt; Endl; * / TiXmlNode * pChild; (PChild = p-parent-> FirstChild (); pChild! = 0; pChild = pChild-> Next Editing ()) {Out & lt; & Lt; PChild; } Exit; }  

Comments