If you are using TinyXml with MFC, remember to add the following line
#include "stdafx.h"
to the top of the the source files tinystr.cpp, tinyxml.cpp, and tinyxmlerror.cpp, tinyxmlparser.cpp to prevent compilation error in MFC project.
Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts
Monday, July 22, 2013
Tuesday, July 16, 2013
Reading Xml in PHP using SimpleXML
suppose you have an xml file "sample.xml" on your server with the following content:
<samples>
<sample index="1" value="0.3" />
<sample index="2" value="0.332" />
<sample index="3" value="0.83" />
<sample index="4" value="0.23" />
</samples>
The following codes will transform the above xml file into a html table using SimpleXML:
<?php
echo "<table>";
$filepath="sample.xml";
$xml=simplexml_load_file($filepath);
foreach($xml->children() as $child)
{
$index=$child->attributes()->index;
$val=$child->attributes()->value;
echo "<tr><td>".$index."</td><td>".$val."</td></tr>";
}
echo "</table>";
?>
<samples>
<sample index="1" value="0.3" />
<sample index="2" value="0.332" />
<sample index="3" value="0.83" />
<sample index="4" value="0.23" />
</samples>
The following codes will transform the above xml file into a html table using SimpleXML:
<?php
echo "<table>";
$filepath="sample.xml";
$xml=simplexml_load_file($filepath);
foreach($xml->children() as $child)
{
$index=$child->attributes()->index;
$val=$child->attributes()->value;
echo "<tr><td>".$index."</td><td>".$val."</td></tr>";
}
echo "</table>";
?>
Tuesday, July 9, 2013
Add TinyXml support to Qt Application
Download and unzip the tinyxml in the project folder of the Qt application. cd to the Qt project folder and enter the following command in the command prompt:
$qmake -project
This will generate the xxx.pro (where xxx refers to the name of the Qt project folder), in the xxx.pro insert the following lines below the line starting with "TARGET = ":
DEPENDPATH += . tinyxml
INCLUDEPATH += . tinyxml
$qmake -project
This will generate the xxx.pro (where xxx refers to the name of the Qt project folder), in the xxx.pro insert the following lines below the line starting with "TARGET = ":
DEPENDPATH += . tinyxml
INCLUDEPATH += . tinyxml
Tuesday, January 11, 2011
Create and Send Xml in php
To create and send xml in php, the php code looks like this:
<?php
// Start XML file, create parent node
$doc = new DOMDocument();
$doc->formatOutput = true;
$node = $doc->createElement("rootnode");
$parnode = $doc->appendChild($node);
<?php
// Start XML file, create parent node
$doc = new DOMDocument();
$doc->formatOutput = true;
$node = $doc->createElement("rootnode");
$parnode = $doc->appendChild($node);
$node = $doc->createElement("childnode");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("description", "Some Description Text");
$xmlfile = $doc->saveXML();
header("Content-type: text/xml");
echo $xmlfile;
?>
Subscribe to:
Posts (Atom)