XML/Input: Difference between revisions
Content deleted Content added
No edit summary |
|||
Line 214: | Line 214: | ||
=={{header|C++}}== |
=={{header|C++}}== |
||
<lang c++ |
<lang c++> |
||
/* |
|||
Using the Qt library's XML parser. |
|||
*/ |
|||
#include <iostream> |
#include <iostream> |
||
#include <QDomDocument> |
|||
⚫ | |||
#include <QObject> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
std::string::size_type ende = 0 ; |
|||
std::string::size_type found = input.find( "<Student" , 0 ) ; |
|||
while ( found != std::string::npos ) { |
|||
found = input.find( "Name" , found + 7 ) ; |
|||
ende = input.find( "\"" , found + 7 ) ; |
|||
if ( ende != std::string::npos ) |
|||
std::cout << input.substr( found + 6 , ende - ( found + 6 ) ) << |
|||
⚫ | |||
found = input.find( "<Student" , ende + 1 ) ; |
|||
⚫ | |||
return 0 ; |
|||
⚫ | |||
⚫ | |||
QDomDocument doc; |
|||
doc.setContent( |
|||
QObject::tr( |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
QDomElement n = doc.documentElement().firstChildElement("Student"); |
|||
while(!n.isNull()) { |
|||
std::cout << qPrintable(n.attribute("Name")) << std::endl; |
|||
n = n.nextSiblingElement(); |
|||
⚫ | |||
⚫ | |||
} |
|||
⚫ | |||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |