?
Solved

TinyXML question

Posted on 2010-09-11
2
Medium Priority
?
590 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 2000 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is about my first experience with programming Arduino.
Introduction to Processes
Starting up a Project
Suggested Courses
Course of the Month8 days, 2 hours left to enroll

765 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