473,386 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Tinyxml document to string!

Meetee
931 Expert Mod 512MB
Hi,

I want to convert tinyxml document file into string. I have found on google as well as tinyxml document but I haven't solve it. What I have done so far is

Expand|Select|Wrap|Line Numbers
  1. TiXmlDocument doc("xyz.xml");
  2. TiXmlElement * root = new TiXmlElement( "login" );
  3. root->SetAttribute("username","name");
  4. root->SetAttribute("password", "pwd");
  5. doc.LinkEndChild(root);
  6. doc.SaveFile();
  7. String str = "";
  8.  
I want to insert the file xyz.xml data into this string str. If it is char*, then it is also ok. Can anybody help me?

Regards
Jul 31 '07 #1
7 9270
jkmyoung
2,057 Expert 2GB
I suggest not using TinyXml. Is it possible for you to use a W3C dom, or JavaDOM instead?
Aug 1 '07 #2
Meetee
931 Expert Mod 512MB
I suggest not using TinyXml. Is it possible for you to use a W3C dom, or JavaDOM instead?
No I can't do that. My project is more than half done. And I can't change it. Little help on this issue please.

Regards
Aug 1 '07 #3
jkmyoung
2,057 Expert 2GB
http://www.grinninglizard.com/tinyxm...lDocument.html
I suggest using function SaveFile (const char *filename) to save the xml file to a
temporary file.

Then use a BufferedReader over a FileReader or other similar class to read the data from the file.
http://java.sun.com/j2se/1.4.2/docs/...redReader.html

BufferedReader in = new BufferedReader(new FileReader("foo.in"));
..
String line = in.readLine();


The other hellish looking way, is to cast the Document as an TiXmlNode, and use regression to output itself. This is a lot more complicated, and is not recommended.
Aug 7 '07 #4
Meetee
931 Expert Mod 512MB
http://www.grinninglizard.com/tinyxm...lDocument.html
I suggest using function SaveFile (const char *filename) to save the xml file to a
temporary file.

Then use a BufferedReader over a FileReader or other similar class to read the data from the file.
http://java.sun.com/j2se/1.4.2/docs/...redReader.html

BufferedReader in = new BufferedReader(new FileReader("foo.in"));
..
String line = in.readLine();


The other hellish looking way, is to cast the Document as an TiXmlNode, and use regression to output itself. This is a lot more complicated, and is not recommended.
Hey thanks jkmyoung,

Can I convert document into string directly without use of file?

Regards
Aug 8 '07 #5
jkmyoung
2,057 Expert 2GB
Perhaps, using bool TiXmlDocument.SaveFile (const std::string &filename) const

I've never used Tinyxml myself before.
Aug 8 '07 #6
Meetee
931 Expert Mod 512MB
Perhaps, using bool TiXmlDocument.SaveFile (const std::string &filename) const

I've never used Tinyxml myself before.
TiXmlDocument.SaveFile (const std::string &filename) const takes filename (xyz.txt) as a parameter.

Anyways thanks for your concern... I think experts can help me in this issue. I am stuck badly :(

Regards
Aug 9 '07 #7
Meetee
931 Expert Mod 512MB
Hi,

I have found the other solution. TiXmlPrinter is required for this, which will store document in buffer.

Thanks all for spending valueable time.

Regards
Aug 18 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Rui Maciel | last post by:
Hi there I'm trying to learn how to handle XML information on C++ files. To start off, I'm trying to use the TinyXML library. The thing is, I'm not having muck success using the library and it...
8
by: Phil Powell | last post by:
if (document.location.href.indexOf('?') >= 0) document.location.href = document.location.href.substring(0, document.location.href.indexOf('?')); if (document.location.href.indexOf('#') >= 0) {...
4
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400,...
1
by: Singee15 | last post by:
How do i go about loading an xml file from a webpage to be used in TinyXML? example: Load from http://www.somepage.com/thexml.xml Any help would be great, thanks!
3
by: Singee15 | last post by:
How do i go about loading an xml file from a webpage to be used in TinyXML? example: Load from http://www.somepage.com/thexml.xml Any help would be great, thanks!
0
by: Nata | last post by:
hi all i am trying to store the XML Document object into MS SQL2005 i want to store this as whole not different tables; plz help me regarding this i am trying form last two weeks i asked many...
0
Meetee
by: Meetee | last post by:
Hi.. I have created an XML file which contains username and password. I want to parse this XML file so that username and password can be stored in database. I am using TinyXML and want to parse...
0
by: thomas.frendo | last post by:
Hi, I'm trying to store some elements of TinyXml in a 2d std::vector here is my code #include "stdafx.h" #include "tinyxml.h" #include <vector>
9
by: abhishekltil | last post by:
hello, can you please help me in reading this sample xml using tinyxml library. <?xml version="1.0" encoding="ISO-8859-1"?> <Configuration> <Parameter name="loglevel" value="3"/>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.