Solved

TinyXML question

Posted on 2010-09-11
2
567 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
When there is a disconnect between the intentions of their creator and the recipient, when algorithms go awry, they can have disastrous consequences.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

749 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