Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Not an issue but a question about copying a XMLElement

Aperta
#1,006 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
22/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
cpp
Ambito
data

Direzione di ricerca

The question is about XMLNode::DeepClone and XMLDocument::Print in tinyxml2.h and tinyxml2.cpp. Read how DeepClone attaches the cloned node to the target document, then check whether the copied <default> element is ever inserted under the new document's root before Print runs. Done means a reproduction that prints the copied subtree, plus a clear answer in the issue or docs on copying a subtree.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I have bumbled my way along with using this library and everything has worked great.

Now I have a need to store a XMLElement from the document for processing later in my code.

In general my XML document looks like this (with simplified attributes):
<tags>
<tag>
<data now=""/>
<data now=""/>
<default>
<data extra=""/>
<data extra=""/>
</default>
</tag>
</tags>

The <tag><data ...> stuff is all working fine.

I want to copy the whole <default>...</default> part to something (maybe a XMLDocument in my class data?) so I can process it later when needed. Is this possible?

I tried this, thinking I would at least be able to print and view the copied element. But all I get is the printf() message:
XMLElement *element ;
element = tag_element->FirstChildElement("default");
if (element) {
printf("tag has default data\n");
XMLDocument doc;
element->DeepClone(&doc);
doc.Print();
}

Any help would be appreciated.

Lingua principale
C++
Stelle
5.8k
Fork
2k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di leethomason/tinyxml2

Tutte le issue di leethomason/tinyxml2

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.