Solved

TinyXML question

Posted on 2010-09-11
2
544 Views
Last Modified: 2012-05-10
Hello,
please give me some hint how to write a node like:
"<METADATA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">"
with TinyXML. A normal node I write like attached code sample.

Ocrana
void xmldata::AddNodeAndText( TiXmlNode* pParent, const char* pszNodeName, const std::wstring &text )
{
	TiXmlElement* pElem = new TiXmlElement( pszNodeName ); // the new node/element

	char* pszText = new char[ (int) text.size() + 1 ];
	::WideCharToMultiByte( CP_ACP, 0, text.c_str(), (int) text.size() + 1, 
		pszText, (int) text.size() + 1, NULL, NULL  );

	// add the text
	TiXmlText *pText = new TiXmlText( pszText	);
	pElem->LinkEndChild( pText );

	pParent->LinkEndChild( pElem ); // add it to parent well

	delete [] pszText;
}

Open in new window

0
Comment
Question by:Ocrana
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 33655064
I am a bit rusty here, but IIRC that should be like
	TiXmlElement* pElem = new TiXmlElement ( "METADATA");



	pElem->SetAttribute ( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"");

	pElem->SetAttribute ( "xmlns:xsd", "http://www.w3.org/2001/XMLSchema");

Open in new window

0
 

Author Closing Comment

by:Ocrana
ID: 33749960
Great solution. Thanks!!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A short article about problems I had with the new location API and permissions in Marshmallow
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now