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"/>
-
<Parameter name="newparam" value="some value"/>
-
<Process Name="osis">
-
<App ID="1" Name="TATA ADC" LogPath="C:\Projects\TATA\TATA\TATA ADC\Test" SeparatorLine="======">
-
<LineFormat Separator="|">
-
<LinePart>Timestamp</LinePart>
-
<LinePart>InformationType</LinePart>
-
<LinePart>Message</LinePart>
-
</LineFormat>
-
<Block StartKeyword="processing fail"/>
-
<Block StartKeyword="processing chain"/>
-
<MailRecipient>ABCD@ABC.com</MailRecipient>
-
</App>
-
<App ID="1" Name="TATA Loader" LogPath="C:\Projects\TATA\TATA\TATA Loader\Test" SeparatorLine="---------">
-
<LineFormat Separator="|">
-
<LinePart>Timestamp</LinePart>
-
<LinePart>InformationType</LinePart>
-
<LinePart>Message</LinePart>
-
<LinePart>Detail</LinePart>
-
<LinePart>Location</LinePart>
-
</LineFormat>
-
<Block StartKeyword="processing"/>
-
<MailRecipient>ABCD@ABC.com</MailRecipient>
-
<Alert Level="error"/>
-
</App>
-
</Process>
-
<Process Name="Ation">
-
<App ID="1" Name="ADA" LogPath="C:\Progloc\ADA" SeparatorLine="">
-
<LineFormat Separator=" ">
-
<LinePart>Timestamp</LinePart>
-
<LinePart>Message</LinePart>
-
</LineFormat>
-
<Block StartKeyword="performing"/>
-
<MailRecipient>ABCD@ABC.com</MailRecipient>
-
</App>
-
</Process>
-
<MailServer>smtp.intra.ABC.com</MailServer>
-
<MailSender>ABCDE@ABC.com</MailSender>
-
</Configuration>
It's a bit urgent, please help me now.
9 26356
I've framed in a bit of code to help you process this file. You have a lot in there, so what I gave you should be enough to get you started. I haven't included much cleanup or error handling, just implemented some basic parsing for you.
The output of the following code will look like this: test.xml loaded
Parameter: name= 'loglevel', value='3'
Parameter: name= 'newparam', value='some value'
Process: osis
..App: ID=1, name=TATA ADC
..App: ID=1, name=TATA Loader
Process: Ation
..App: ID=1, name=ADA -
// Load the xml file, I put your XML in a file named test.xml
-
TiXmlDocument XMLdoc("test.xml");
-
bool loadOkay = XMLdoc.LoadFile();
-
if (loadOkay)
-
{
-
cout << "test.xml loaded" << endl;
-
TiXmlElement *pRoot, *pParm, *pProcess, *pApp, *pLineFormat;
-
pRoot = XMLdoc.FirstChildElement( "Configuration" );
-
if ( pRoot )
-
{
-
// Parse parameters
-
pParm = pRoot->FirstChildElement("Parameter");
-
while ( pParm )
-
{
-
cout << "Parameter: name= '" << pParm->Attribute("name") << "', value='" << pParm->Attribute("value") << "'" << endl;
-
pParm = pParm->NextSiblingElement( "Parameter" );
-
}
-
-
cout << endl;
-
-
// Parse Process
-
pProcess = pRoot->FirstChildElement("Process" );
-
while ( pProcess )
-
{
-
cout <<"Process: " << pProcess->Attribute("Name" ) << endl;
-
pApp = pProcess->FirstChildElement("App" );
-
while ( pApp )
-
{
-
cout << "..App: ID=" << pApp->Attribute("ID") << ", name=" << pApp->Attribute("Name") << endl;
-
-
// ***************************************************
-
// * TODO: Put code in to handle the App details
-
// ***************************************************
-
-
pApp = pApp->NextSiblingElement("App");
-
}
-
-
pProcess = pProcess->NextSiblingElement("Process");
-
}
-
}
-
else
-
{
-
cout << "Cannot find 'Configuration' node" << endl;
-
}
-
-
I hope this helps
Bill
<removed>
- <?xml version="1.0"?>
-
<Planning>
-
<TwoDobject>
-
<Coordinates>
-
<Octagonshape>
-
<Firstmodel>
-
<Vertex x="0.000002" y="0.000004" z="0.00"> </Vertex>
-
<Vertex x="0.000002" y="0.000005" z="0.00"> </Vertex>
-
<Vertex x="0.000003" y="0.000006" z="0.00"> </Vertex>
-
<Vertex x="0.000004" y="0.000006" z="0.00"> </Vertex>
-
<Vertex x="0.000005" y="0.000005" z="0.00"> </Vertex>
-
<Vertex x="0.000005" y="0.000004" z="0.00"> </Vertex>
-
<Vertex x="0.000004" y="0.000003" z="0.00"> </Vertex>
-
<Vertex x="0.000003" y="0.000003" z="0.00"> </Vertex>
-
</Firstmodel>
-
</Octagonshape>
-
<Rectangleshape>
-
<Firstmodel>
-
</Firstmodel>
-
</Rectangleshape>
-
</Coordinates>
-
<Firstscene>
-
<Octagonshape>
-
<Firstmodel>
-
<Transformation x="0.0000035" y="0.0000045" theta=0.0> </Transformation>
-
</Firstmodel>
-
</Octagonshape>
-
<Rectangleshape>
-
<Firstmodel>
-
</Firstmodel>
-
</Rectangleshape>
-
</Firstscene>
-
</TwoDobject>
-
<ThreeDobject>
-
</ThreeDobject>
-
</Planning>
Hi I have this xml file. I want to parse this . Can anyone help me.
Thanks
Sagar
Thanks Dormillich. Actually, I have no experience in PHP. Basically, I want to put all the information in the xml file into a data structure. But I dont know how to do that? Can you help me with some logic.
Sagar
@sagar353
you didn’t say anything about what language you wanted to use. PHP is simply one of the languages I’m good at. @sagar353
what kind of structure, arrays, objects, …?
Hi Dormilich,
I want to define different classes and objects where I will store the information in a structured way. Thanks
Sagar
you mean something like serialization?
one exchangeable serializer is WDDX…
I dont know what WDDX mean. Since I already organize my XML file, serialization will work probably.
Thanks
Sagar
WDDX is a XML based serializer.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tony Stock |
last post by:
Hi all,
problem - need to read a log (text) file looking for certain entries,
this file will still be written to by another 3rd party process, and
hence constantly require monitoring (dare I say...
|
by: syntax |
last post by:
hi, i want to read a file using fread() in equal chunks through a for
loop so that at the last call i dont get error..which way, i should
read it?
let me give an example, suppose i have 100...
|
by: Pedro Bautista |
last post by:
Status: Unsolved and puzzling
Steps to reproduce the error:
1.- Delete IUSER from server
2.- Reboot server (OS rebuilds IUSR)
3.- Assign IUSR read and execute permission on web folder
and...
|
by: Bill Nguyen |
last post by:
I wonder if I can write to an XML file using column structure (and column
names) of an SQLserver table.
for example:
Table A:
column1 int
column2 char(30)
column3 date
XML output:
|
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...
|
by: SM |
last post by:
Hello,
Im trying to access elements in my XML file using the JavaScript DOM
but i'm not sure how. I use AJAX to access the XML and then use the
responseXML property to access the XML file data.
I...
|
by: Studlyami |
last post by:
Is it possible to open a file for reading, while another process has it open for writing to it? One of the problems is that the process that is writing to it is written in C and is running on a...
|
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...
|
by: bjoarn |
last post by:
I have an Application C# handling file reading, building index on this file, using dll wrapped with SWIG. The dll is originaly programmed in C++.
Dll reports back to the the C# programm throug...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |