Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » XmlNode class is excellent (My experience with XmlNode)
XmlNode class is excellent [message #43526] Tue, 19 August 2014 17:47 Go to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello all

I have externally produced .XML files to analyze. After some fear to begin, I used ParseXML and XmlNode functions and, it was great. Very very easy, simple and robust functions to fully read a XML. Surprisingly, first version in minutes Very Happy

Excellent experience.


Best regards
Iñaki
Re: XmlNode class is excellent [message #43799 is a reply to message #43526] Thu, 16 October 2014 10:12 Go to previous messageGo to next message
akebee is currently offline  akebee
Messages: 90
Registered: August 2011
Location: China
Member
i don`t think the xml package is very easy to use Crying or Very Sad
can you tell me how to use Shocked
Re: XmlNode class is excellent [message #43801 is a reply to message #43799] Sat, 18 October 2014 01:41 Go to previous message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
XML file and code to begin parsing it:

String xml = LoadFile(fileName);
		
try {
	XmlNode xn = ParseXML(xml);
			
	const XmlNode &nodeVariables = xn["dae"]["variables"];
	const XmlNode &nodeOrderedVariables = nodeVariables["orderedVariables"]["variablesList"];

	for (int i = 0; i < nodeOrderedVariables.GetCount(); ++i) 
		Cout() << "\n " << nodeOrderedVariables[i].Attr("name");
...


Xml sample:
<?xml version="1.0" encoding="UTF-8"?>
<dae xmlns:p1="http://www.w3.org/1998/Math/MathML"
                                                xmlns:xlink="http://www.w3.org/1999/xlink"
                                                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                                xsi:noNamespaceSchemaLocation="http://home.dei.polimi.it/donida/Projects/AutoEdit/Images/DAE.xsd">
<variables dimension="7">
<orderedVariables dimension="5">
<variablesList>
<variable id="1" name="v_new" variability="discrete" direction="none" type="Real" fixed="false" flow="NonConnector" stream="NonStreamConnector">
<classesNames>
<element>
BouncingBall
</element>
<element>
Real
</element>
</classesNames>
</variable>
<variable id="2" name="impact" variability="discrete" direction="none" type="Boolean" fixed="false" flow="NonConnector" stream="NonStreamConnector">
<classesNames>
<element>
BouncingBall
</element>
<element>
Boolean
</element>
</classesNames>
</variable>
<variable id="3" name="flying" variability="discrete" direction="none" type="Boolean" fixed="false" flow="NonConnector" stream="NonStreamConnector" comment="true, if ball is flying">
<classesNames>
<element>
BouncingBall
</element>
<element>
Boolean
</element>
</classesNames>
<attributesValues>
<initialValue string="true">
</initialValue>
</attributesValues>
</variable>
<variable id="4" name="v" variability="continuousState" direction="none" type="Real" differentiatedIndex="1" fixed="false" flow="NonConnector" stream="NonStreamConnector" comment="velocity of ball">
<classesNames>
<element>
BouncingBall
</element>
<element>
Real
</element>
</classesNames>
</variable>
<variable id="5" name="h" variability="continuousState" direction="none" type="Real" differentiatedIndex="1" derivativeName="v" fixed="false" flow="NonConnector" stream="NonStreamConnector" comment="height of ball">
<classesNames>
<element>
BouncingBall
</element>
<element>
Real
</element>
</classesNames>
<attributesValues>
<initialValue string="5.0">
</initialValue>
</attributesValues>
</variable>
</variablesList>
</orderedVariables>
<knownVariables dimension="2">
<variablesList>
<variable id="1" name="g" variability="parameter" direction="none" type="Real" fixed="true" flow="NonConnector" stream="NonStreamConnector" comment="gravity acceleration">
<bindValueExpression>
<bindExpression string="9.81">
</bindExpression>
</bindValueExpression>
<classesNames>
<element>
BouncingBall
</element>
<element>
Real
</element>
</classesNames>
</variable>
<variable id="2" name="e" variability="parameter" direction="none" type="Real" fixed="true" flow="NonConnector" stream="NonStreamConnector" comment="coefficient of restitution">
<bindValueExpression>
<bindExpression string="0.8">
</bindExpression>
</bindValueExpression>
<classesNames>
<element>
BouncingBall
</element>
<element>
Real
</element>
</classesNames>
</variable>
</variablesList>
</knownVariables>
</variables>
<equations dimension="5">
<equation id="1">impact = h &lt;= 0.0
</equation>
<equation id="2">der(v) = if flying then -g else 0.0
</equation>
<equation id="3">der(h) = v
</equation>
<whenEquation id="4">v_new := if impact and not pre(impact) then (-e) * pre(v) else 0.0
<whenEquationCondition>
{impact and v &lt;= 0.0, impact}
</whenEquationCondition>
</whenEquation>
<whenEquation id="5">flying := v_new &gt; 0.0
<whenEquationCondition>
{impact and v &lt;= 0.0, impact}
</whenEquationCondition>
</whenEquation>
</equations>
<WhenClausesList dimension="1">
<WhenClause index="1">
<whenEquationCondition>
{impact and v &lt;= 0.0, impact}
</whenEquationCondition>
<WhenOperatorsList dimension="1">
<WhenOperator>
reinit(v, v_new)
</WhenOperator>
</WhenOperatorsList>
</WhenClause>
</WhenClausesList>
<zeroCrossingList dimension="3">
<zeroCrossingElement string="h &lt;= 0.0">
<involvedEquations>
<equationId>
1
</equationId>
</involvedEquations>
</zeroCrossingElement>
<zeroCrossingElement string="impact and v &lt;= 0.0">
<involvedEquations>
<equationId>
4
</equationId>
</involvedEquations>
</zeroCrossingElement>
<zeroCrossingElement string="v &lt;= 0.0">
<involvedEquations>
<equationId>
5
</equationId>
</involvedEquations>
</zeroCrossingElement>
</zeroCrossingList>
<functions>
</functions>
</dae>


Best regards
Iñaki

[Updated on: Sat, 18 October 2014 01:42]

Report message to a moderator

Previous Topic: A Very Strange Issue
Next Topic: How to get value from parent AppWindow class?
Goto Forum:
  


Current Time: Fri Mar 29 11:44:04 CET 2024

Total time taken to generate the page: 0.01431 seconds