473,385 Members | 1,185 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,385 software developers and data experts.

XML generation using TinyXML

I have written the following classes to generate an XML which is as below:

Expand|Select|Wrap|Line Numbers
  1. <JBEToOverseerRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///c:/Share/resquest.xsd">
  2.     <ConfigParams>        
  3.            <Param Name="OverseerConfJBEPortNum">1025</Param>
  4.            <Param Name="OverseerConfHctHostname">10.31.225.163</Param>
  5.            <Param Name="OverseerConfTestExecParallelism">5</Param>
  6.            <Param Name="OverseerConfServerName">10.31.225.163</Param>
  7.            <Param Name="OverseerDirectory">C:\Documents and Settings\Administrator\Desktop\Pocdemo</Param>
  8.            <Param Name="OverseerConfKillThreadUsingKillerThread">Yes</Param>
  9.  
  10.            <Param Name="OverseerTimeoutCleanup">yes</Param>
  11.      </ConfigParams>
  12.  
  13.      <Requests>
  14.          <Request>
  15.               <RequestID>HC1001</RequestID>
  16.               <Host>hct-nw-server</Host>
  17.               <Parameters>
  18.                   <Param Name="RequestNumber">1</Param>
  19.                   <Param Name="TimeOut">120</Param>
  20.               </Parameters>
  21.         </Request>
  22.  
  23.         <Request>
  24.               <RequestID>HC1001</RequestID>
  25.               <Host>hct-nw-client</Host>
  26.               <Parameters>
  27.                   <Param Name="RequestNumber">2</Param>
  28.                   <Param Name="TimeOut">120</Param>
  29.               </Parameters>        
  30.         </Request> 
  31.       </Requests>
  32. </JBEToOverseerRequest>
Classes are:
Expand|Select|Wrap|Line Numbers
  1. #include<io.h>
  2. #include<string>
  3. #include<list>
  4. #include<tinyxml.h>
  5.  
  6. using namespace std;
  7.  
  8. class Param
  9. public:
  10.     string value;
  11.     string name;
  12.  
  13.     Param();
  14.  
  15.     Param( string value, string name)
  16.     { 
  17.       this->value=value;
  18.       this->name=name;
  19.     }
  20.  
  21. };
  22.  
  23.  
  24. class Parameters
  25. {
  26. public:
  27.     list<Param> param;
  28.  
  29.     Parameters();
  30.     Parameters(list<Param> param)
  31.      {
  32.          this->param = param;
  33.      }
  34.  
  35. };
  36.  
  37.  
  38. class Request
  39. {
  40. public:
  41.     string requestID;
  42.     string host;
  43.     Parameters parameters;
  44.  
  45.     Request();
  46.     Request(string requestID, string host, Parameters parameters)
  47.     {
  48.          this->requestID = requestID;
  49.          this->host = host;
  50.          this->parameters = parameters;
  51.     }
  52. };
  53.  
  54.  
  55. class Requests
  56. {
  57. public:
  58.     list<Request> requests;
  59.  
  60.     Requests();
  61.     Requests(list<Request> requests)
  62.     { 
  63.         this->requests = requests;
  64.     }
  65. };
  66.  
  67.  
  68. class JBEToOverseerRequest
  69. {
  70. public:
  71.     Parameters configParams;
  72.     Requests requests;
  73.  
  74.     JBEToOverseerRequest();
  75.     JBEToOverseerRequest(Parameters configparams, Requests requests)
  76.     {
  77.         this->configParams=configparams;
  78.         this->requests=requests;
  79.     }
  80.  
  81.     void save(const char* Filename);
  82. };
  83.  
  84. class ConfigParams
  85. {
  86. public:
  87.     Parameters configparams;
  88.  
  89.     ConfigParams();
  90.     ConfigParams(Parameters configparams)
  91.     {
  92.         this->configparams = configparams;
  93.     }
  94. };
  95.  
  96. void JBEToOverseerRequest::save(const char* Filename)
  97. {
  98.  
  99.     TiXmlDocument doc;  
  100.     TiXmlElement* msg;
  101.  
  102.      TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );  
  103.     doc.LinkEndChild( decl ); 
  104.  
  105.     TiXmlElement * root = new TiXmlElement("JBEToOverseerRequest");  
  106.     doc.LinkEndChild( root );  
  107.  
  108.     //block configparams
  109.     {
  110.     TiXmlElement * configparams= new TiXmlElement( "ConfigParams" );  
  111.     root->LinkEndChild( configparams ); 
  112.  
  113.     Param param1=Param("OverseerConfJBEPortNum", "1844");
  114.     Param param2=Param("OverseerConfHctHostname" ," 10.30.89.117");
  115.     Param param3=Param("OverseerConfTestExecParallelism", "5");
  116.     Param param4=Param("OverseerConfServerName", "10.30.89.117");
  117.     Param param5=Param("OverseerDirectory","NSR_TMP_DIRECTORY");
  118.     Param param6=Param("OverseerTimeoutCleanup","yes");
  119.     Param param7=Param("JBEcategory","HostConnectivity");
  120.     Param param8=Param("JBECheckType","Extended");
  121.     Param param9=Param("ReportRuns","4");
  122.     Param param10=Param("ReportGrouping","RUNS");
  123.     Param param11=Param("FilterType","N_RUNS");
  124.     Param param12=Param("ExportDirPath","//diagnose");
  125.     Param param13=Param("CancelInMillisec","0");
  126.  
  127.      list<Param> params =list<Param>();
  128.      list <Param>::iterator Iter;
  129.  
  130.      Iter=params.begin();
  131.      params.insert(Iter,param1);
  132.      params.insert(Iter,param2);
  133.      params.insert(Iter,param3);
  134.      params.insert(Iter,param4);
  135.      params.insert(Iter,param5);
  136.      params.insert(Iter,param6);
  137.      params.insert(Iter,param7);
  138.      params.insert(Iter,param8);
  139.      params.insert(Iter,param9);
  140.      params.insert(Iter,param10);
  141.      params.insert(Iter,param11);
  142.      params.insert(Iter,param12);
  143.      params.insert(Iter,param13);
  144.  
  145.      Parameters parameters=Parameters(params);
  146.  
  147.      ConfigParams configparams=ConfigParams(parameters);
  148. }
But i dont know how to encode these classes into XML form.
Can you help ? Urgently.
Apr 24 '12 #1
0 1885

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

Similar topics

0
by: raji20 | last post by:
Hello Guys, Im using pdflib for generating pdf, It is working fine, when I used a single page pdf as the template, but when I use a pdf with two pages I dont know how to write in first page and...
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...
4
by: wassimdaccache | last post by:
Hello everybody Does someone have a VB module and FONT for windows XP SP2 to import into a MSaccess (2003) to print a barecode ... Please leave me any comments about barecode generation...
1
by: miroconnect | last post by:
I want to generate a integer which should be combination of 2 integer and one int and anytime I call generate it should generate same value for same input and for different combinations it should...
1
by: javakid | last post by:
Hi I am generating RSS feed XML, I am using SyndFeed Object for this generation. I am able to generate subelement of Channel as Title, Link, Description. I also want to generate Generator tag....
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"/>...
6
by: James Arnold | last post by:
Hello, I am new to C and I am trying to write a few small applications to get some hands-on practise! I am trying to write a random string generator, based on a masked input. For example, given...
5
by: cwinay | last post by:
Hi, I'm a novice in JSTL and Infoglue. Could anyone please let me know how I can generate a Sitemap component using these two? I need the component to have just one property ie the HomePage. Given...
0
by: modykun | last post by:
Reading an XML here is a must for my need I have to say though that i don't have any previous XML experience , so I'm not sure how to make it read it I'm using TinyXML , because i need fast code...
1
by: newphpcoder | last post by:
Good day! I upgrade my version of mysql from mysql 4.1.10 to mysql 5.0.15. Now I used phpmyadmin to access my database using XAMPP. Now, I need to create a report generation and I have no idea how I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.