How to convert vtkpolydata into vtkimagedata? - c++

In vtp ( or xml? ) files I have a set of points with position (x,y,z), mass (m) and densities (rho) for each points.
They look like so
<?xml version="1.0"?>
<VTKFile type="PolyData" version="0.1" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
<PolyData>
<Piece NumberOfPoints="524288" NumberOfVerts="0" NumberOfLines="0" NumberOfStrips="0" NumberOfPolys="0" >
<PointData>
<DataArray type="Float32" Name="vx" format="appended" RangeMin="-10617.716797" RangeMax="11650.322266" offset="0" />
<DataArray type="Float32" Name="vy" format="appended" RangeMin="-12008.198242" RangeMax="11676.560547" offset="2554076" />
<DataArray type="Float32" Name="vz" format="appended" RangeMin="-10880.447266" RangeMax="11361.508789" offset="5104080" />
<DataArray type="Float32" Name="mass" format="appended" RangeMin="0.16916139424" RangeMax="0.83083856106" offset="7655432" />
<DataArray type="Float32" Name="uu" format="appended" RangeMin="0" RangeMax="117252.91406" offset="7742064" />
<DataArray type="Float32" Name="hh" format="appended" RangeMin="0" RangeMax="4.1185030937" offset="8877700" />
<DataArray type="Float32" Name="mu" format="appended" RangeMin="1.2307692766" RangeMax="1.2307692766" offset="10032668" />
<DataArray type="Float32" Name="rho" format="appended" RangeMin="0" RangeMax="49503150080" offset="10038236" />
<DataArray type="Float32" Name="phi" format="appended" RangeMin="-1.3579902649" RangeMax="1.2645899057" offset="11265024" />
<DataArray type="Int64" Name="id" format="appended" RangeMin="0" RangeMax="524287" offset="13840232" />
<DataArray type="UInt16" Name="mask" format="appended" RangeMin="0" RangeMax="3" offset="15044924" />
</PointData>
<CellData>
</CellData>
<Points>
<DataArray type="Float32" Name="Points" NumberOfComponents="3" format="appended" RangeMin="0.89113022864" RangeMax="110.020575" offset="15133592" />
</Points>
<Verts>
<DataArray type="Int64" Name="connectivity" format="appended" RangeMin="" RangeMax="" offset="22080132" />
<DataArray type="Int64" Name="offsets" format="appended" RangeMin="" RangeMax="" offset="22080148" />
</Verts>
<Lines>
<DataArray type="Int64" Name="connectivity" format="appended" RangeMin="" RangeMax="" offset="22080164" />
<DataArray type="Int64" Name="offsets" format="appended" RangeMin="" RangeMax="" offset="22080180" />
</Lines>
<Strips>
<DataArray type="Int64" Name="connectivity" format="appended" RangeMin="" RangeMax="" offset="22080196" />
<DataArray type="Int64" Name="offsets" format="appended" RangeMin="" RangeMax="" offset="22080212" />
</Strips>
<Polys>
<DataArray type="Int64" Name="connectivity" format="appended" RangeMin="" RangeMax="" offset="22080228" />
<DataArray type="Int64" Name="offsets" format="appended" RangeMin="" RangeMax="" offset="22080244" />
</Polys>
</Piece>
</PolyData>
<AppendedData encoding="base64">
...
</AppendedData>
</VTKFile
I would like to use this to do some volume rendering, therefore I need to have it as ImageData.
My first stupid approach is this : using a vtkXMLImageDataReader instead of a vtkXMLPolyDataReader. It obviously didn't work.
What can I do to convert it to ImageData or make it work with any volumeMapper?
Thanks

With vtkplotter you can create a vtkVolume interpolating from a sparse set of points:
from vtkplotter import *
mymesh = ... # vtkPolyData with pointdata
vol = interpolateToVolume(Actor(mymesh))
#write(vol, 'output.vti')
show(vol)
see here.

I might be missing something in the question. But from my understanding, you can simpy follow this example: link

Related

How to set c++ boost graphml node and edge id?

I am using the Boost graph to store a set of nodes and edges and then write it to a graphml format. Whatever I do, I cannot find a way to access or set the node id (n0, n1) or edge id (e0) attributes.
It seems to be automatically set.
Is there a way to access and set it manually ?
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<key id="key0" for="node" attr.name="id" attr.type="int" />
<key id="key1" for="edge" attr.name="length" attr.type="double" />
<key id="key2" for="edge" attr.name="max_speed" attr.type="double" />
<key id="key3" for="node" attr.name="name" attr.type="string" />
<key id="key4" for="edge" attr.name="name" attr.type="string" />
<key id="key5" for="edge" attr.name="source" attr.type="int" />
<key id="key6" for="node" attr.name="station" attr.type="boolean" />
<key id="key7" for="edge" attr.name="target" attr.type="int" />
<key id="key8" for="node" attr.name="theta" attr.type="double" />
<key id="key9" for="node" attr.name="x" attr.type="double" />
<key id="key10" for="node" attr.name="y" attr.type="double" />
<graph id="G" edgedefault="directed" parse.nodeids="canonical" parse.edgeids="canonical" parse.order="nodesfirst">
<node id="n0">
<data key="key0">10000</data>
<data key="key3">node1</data>
<data key="key6">0</data>
<data key="key8">0</data>
<data key="key9">6.95279e-310</data>
<data key="key10">0</data>
</node>
<node id="n1">
<data key="key0">10001</data>
<data key="key3">node1</data>
<data key="key6">0</data>
<data key="key8">0</data>
<data key="key9">6.95279e-310</data>
<data key="key10">0</data>
</node>
<edge id="e0" source="n0" target="n1">
<data key="key1">6.95279e-310</data>
<data key="key2">150</data>
<data key="key4"></data>
<data key="key5">-127787376</data>
<data key="key7">21994</data>
</edge>
</graph>
</graphml>
My graph
typedef typename boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS,
GpNode, GpEdge>
DirectedGraph;
Where GpNode and GpEdge are custom class definitions.
Thanks in advance
write_graphml takes a dynamic_properties. Let's configure that:
Live On Coliru
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graphml.hpp>
struct GpNode {
int id;
std::string name;
bool station;
double theta;
double x;
double y;
};
struct GpEdge {
double length;
double max_speed;
std::string name;
int source;
int target;
};
using DirectedGraph = boost::adjacency_list<boost::vecS, boost::vecS,
boost::directedS, GpNode, GpEdge>;
int main() {
std::ifstream ifs("input.xml");
DirectedGraph g;
auto n0 = add_vertex(
GpNode{
10000, // id
"node1", // name
0, // station
0, // theta
6.95279e-310, // x
0, // y
}, g);
auto n1 = add_vertex(
GpNode{
10001, // id
"node1", // name
0, // station
0, // theta
6.95279e-310, // x
0, // y
}, g);
/*auto e0 = */add_edge(n0, n1,
GpEdge{
6.95279e-310, // length
150, // max_speed
"", // name
-127787376, // source
21994, // target
}, g);
auto vindex = get(&GpNode::id, g);
boost::dynamic_properties dp;
//dp.property("node_id", vindex);
dp.property("id", vindex);
dp.property("name", get(&GpNode::name, g));
dp.property("station", get(&GpNode::station, g));
dp.property("theta", get(&GpNode::theta, g));
dp.property("x", get(&GpNode::x, g));
dp.property("y", get(&GpNode::y, g));
dp.property("length", get(&GpEdge::length, g));
dp.property("max_speed", get(&GpEdge::max_speed, g));
dp.property("name", get(&GpEdge::name, g));
dp.property("source", get(&GpEdge::source, g));
dp.property("target", get(&GpEdge::target, g));
boost::write_graphml(std::cout, g, dp);
}
Prints
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<key id="key0" for="node" attr.name="id" attr.type="int" />
<key id="key1" for="edge" attr.name="length" attr.type="double" />
<key id="key2" for="edge" attr.name="max_speed" attr.type="double" />
<key id="key3" for="node" attr.name="name" attr.type="string" />
<key id="key4" for="edge" attr.name="name" attr.type="string" />
<key id="key5" for="edge" attr.name="source" attr.type="int" />
<key id="key6" for="node" attr.name="station" attr.type="boolean" />
<key id="key7" for="edge" attr.name="target" attr.type="int" />
<key id="key8" for="node" attr.name="theta" attr.type="double" />
<key id="key9" for="node" attr.name="x" attr.type="double" />
<key id="key10" for="node" attr.name="y" attr.type="double" />
<graph id="G" edgedefault="directed" parse.nodeids="free" parse.edgeids="canonical" parse.order="nodesfirst">
<node id="n0">
<data key="key0">10000</data>
<data key="key3">node1</data>
<data key="key6">0</data>
<data key="key8">0</data>
<data key="key9">6.95279e-310</data>
<data key="key10">0</data>
</node>
<node id="n1">
<data key="key0">10001</data>
<data key="key3">node1</data>
<data key="key6">0</data>
<data key="key8">0</data>
<data key="key9">6.95279e-310</data>
<data key="key10">0</data>
</node>
<edge id="e0" source="n0" target="n1">
<data key="key1">6.95279e-310</data>
<data key="key2">150</data>
<data key="key4"></data>
<data key="key5">-127787376</data>
<data key="key7">21994</data>
</edge>
</graph>
</graphml>
Mmm. That took a while. But now I see. I know that write_graphviz_dp assumes node_id is the node id property, but as you can see, I tried and it didn't help
Docs To The Rescue
But, wait, docs show a second overload that also takes VertexIndexMap. Let's.... try that?
boost::write_graphml(std::cout, g, vindex, dp);
Now it prints
Live On Coliru
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<key id="key0" for="node" attr.name="id" attr.type="int" />
<key id="key1" for="edge" attr.name="length" attr.type="double" />
<key id="key2" for="edge" attr.name="max_speed" attr.type="double" />
<key id="key3" for="node" attr.name="name" attr.type="string" />
<key id="key4" for="edge" attr.name="name" attr.type="string" />
<key id="key5" for="edge" attr.name="source" attr.type="int" />
<key id="key6" for="node" attr.name="station" attr.type="boolean" />
<key id="key7" for="edge" attr.name="target" attr.type="int" />
<key id="key8" for="node" attr.name="theta" attr.type="double" />
<key id="key9" for="node" attr.name="x" attr.type="double" />
<key id="key10" for="node" attr.name="y" attr.type="double" />
<graph id="G" edgedefault="directed" parse.nodeids="free" parse.edgeids="canonical" parse.order="nodesfirst">
<node id="n10000">
<data key="key0">10000</data>
<data key="key3">node1</data>
<data key="key6">0</data>
<data key="key8">0</data>
<data key="key9">6.95279e-310</data>
<data key="key10">0</data>
</node>
<node id="n10001">
<data key="key0">10001</data>
<data key="key3">node1</data>
<data key="key6">0</data>
<data key="key8">0</data>
<data key="key9">6.95279e-310</data>
<data key="key10">0</data>
</node>
<edge id="e0" source="n10000" target="n10001">
<data key="key1">6.95279e-310</data>
<data key="key2">150</data>
<data key="key4"></data>
<data key="key5">-127787376</data>
<data key="key7">21994</data>
</edge>
</graph>
</graphml>
That's likely as close as you'll get with it. Changing the id type to std::string doesn't prevent the "n" prefix. (I suppose it's to allow edges to have id's colliding with nodes without problems?)

SSRS XSLT for XML Output - Transform Subset of Attributes to Elements

I'm having trouble wrapping my head around transforming a subset of attributes to child elements. My goal is to have a stylesheet that SSRS can refer to in shaping the output.
The example code I've seen transforms all of the attributes and I can't understand how to be selective.
Here is the source file, output as an XML file from SSRS.
<?xml version="1.0" encoding="utf-8"?>
<Report xsi:schemaLocation="_x0031_4Q_CSV http://MySSRSServer/ReportServer?%2FTRR%20Reports%2F14Q_CSV&rs%3ACommand=Render&rs%3AFormat=XML&rs%3ASessionID=uuurm045z4bsq2maejbbb045&rc%3ASchema=True" Name="14Q_CSV" textbox1="14Q_CSV Period:201711 Publish Date: 12/7/2017 4:38:49 PM" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="_x0031_4Q_CSV">
<table1>
<Detail_Collection>
<Detail ID_RSSD="1037003" D_DT="2017-11-30T00:00:00" CQSCS383="S0004260053" Transtype="I" CQSCF841="2020-01-23T00:00:00" CQSCP082="CUSIP" CQSCP083="31384YCC8" CQSCS370="N" CQSCP084="Agency MBS" CQSCP085="FN 537467" CQSCP087="50768.00" CQSCP088="53330.00" CQSCP089="50667.00" CQSCP090="12484343.00" CQSCP091="0.00" CQSCP092="AFS" CQSCP093="2017-11-30T00:00:00" CQSCP094="0.070363000000" CQSCP095="2000-04-01T00:00:00" CQSCS371="USD" CQSCHK21="105.2563040000" />
<Detail ID_RSSD="1037003" D_DT="2017-11-30T00:00:00" CQSCS383="S0004260054" Transtype="I" CQSCF841="2020-01-23T00:00:00" CQSCP082="CUSIP" CQSCP083="31384YCD6" CQSCS370="N" CQSCP084="Agency MBS" CQSCP085="FN 537468" CQSCP087="96069.00" CQSCP088="106433.00" CQSCP089="96069.00" CQSCP090="12066524.00" CQSCP091="0.00" CQSCP092="AFS" CQSCP093="2017-11-30T00:00:00" CQSCP094="0.067115000000" CQSCP095="2000-04-01T00:00:00" CQSCS371="USD" CQSCHK21="110.7884470000" />
<Detail ID_RSSD="1037003" D_DT="2017-11-30T00:00:00" CQSCS383="S0004260057" Transtype="I" CQSCF841="2020-01-23T00:00:00" CQSCP082="CUSIP" CQSCP083="31384YCH7" CQSCS370="N" CQSCP084="Agency MBS" CQSCP085="FN 537472" CQSCP087="133804.00" CQSCP088="151158.00" CQSCP089="134964.00" CQSCP090="6415504.00" CQSCP091="0.00" CQSCP092="AFS" CQSCP093="2017-11-30T00:00:00" CQSCP094="0.064967000000" CQSCP095="2000-04-01T00:00:00" CQSCS371="USD" CQSCHK21="111.9988700000" />
<Detail ID_RSSD="1037003" D_DT="2017-11-30T00:00:00" CQSCS383="S0004260058" Transtype="I" CQSCF841="2020-01-23T00:00:00" CQSCP082="CUSIP" CQSCP083="31384YCJ3" CQSCS370="N" CQSCP084="Agency MBS" CQSCP085="FN 537473" CQSCP087="188500.00" CQSCP088="198238.00" CQSCP089="186974.00" CQSCP090="7054878.00" CQSCP091="0.00" CQSCP092="AFS" CQSCP093="2017-11-30T00:00:00" CQSCP094="0.074321000000" CQSCP095="2000-04-01T00:00:00" CQSCS371="USD" CQSCHK21="106.0240080000" />
<Detail ID_RSSD="1037003" D_DT="2017-11-30T00:00:00" CQSCS383="S0004260059" Transtype="I" CQSCF841="2020-01-23T00:00:00" CQSCP082="CUSIP" CQSCP083="31384YCK0" CQSCS370="N" CQSCP084="Agency MBS" CQSCP085="FN 537474" CQSCP087="53662.00" CQSCP088="56159.00" CQSCP089="52828.00" CQSCP090="6033726.00" CQSCP091="0.00" CQSCP092="AFS" CQSCP093="2017-11-30T00:00:00" CQSCP094="0.079403000000" CQSCP095="2000-04-01T00:00:00" CQSCS371="USD" CQSCHK21="106.3062160000" />
<Detail ID_RSSD="1037003" D_DT="2017-11-30T00:00:00" CQSCS383="S0004260060" Transtype="I" CQSCF841="2020-01-23T00:00:00" CQSCP082="CUSIP" CQSCP083="31384YCL8" CQSCS370="N" CQSCP084="Agency MBS" CQSCP085="FN 537475" CQSCP087="53958.00" CQSCP088="57002.00" CQSCP089="53518.00" CQSCP090="5710436.00" CQSCP091="0.00" CQSCP092="AFS" CQSCP093="2017-11-30T00:00:00" CQSCP094="0.076705000000" CQSCP095="2000-04-01T00:00:00" CQSCS371="USD" CQSCHK21="106.5098890000" />
</Detail_Collection>
</table1>
</Report>
I need to retain the first four attributes within the Detail node, rename the node as shown, and transform the rest to child elements of the Detail node.
Here is the desired outcome:
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
<SCRTS_Data_Collect LAST_ASOF_TSTMP="2019-11-06T00:00:00.000" DATA_ASOF_TSTMP="2019-11-06T00:00:00.000">
<SCRTS_Data_Collect_MS ID_RSSD="1037003" D_DT="2019-09-30T00:00:00" CQSCS383="S0010160276" TRANSTYPE="I">
<CQSCF841>11/06/2019</CQSCF841>
<CQSCP082>CUSIP</CQSCP082>
<CQSCP083>36202K2Q7</CQSCP083>
<CQSCS370>N</CQSCS370>
<CQSCP084>Agency MBS</CQSCP084>
<CQSCP085>G2 8883</CQSCP085>
<CQSCP087>8917</CQSCP087>
<CQSCP088>9008</CQSCP088>
<CQSCP089>8911</CQSCP089>
<CQSCP090>5200000</CQSCP090>
<CQSCP091>0</CQSCP091>
<CQSCP092>AFS</CQSCP092>
<CQSCP093>09/30/2019</CQSCP093>
<CQSCP094>0.07108</CQSCP094>
<CQSCP095>10/07/2000</CQSCP095>
<CQSCS371>USD</CQSCS371>
<CQSCHK21>101.090333</CQSCHK21>
</SCRTS_Data_Collect_MS>
</SCRTS_Data_Collect>
The stylesheet I've been working on has the following code:
<!-- rule to copy everything else xmlns="_x0031_4Q_CSV" -->
<xsl:template match="*/#*" xmlns="_x0031_4Q_CSV">
<xsl:element name="{name()}">
<xsl:value-of select="."/>
</xsl:element>
<xsl:apply-templates/>
</xsl:template>
Obviously this transforms all of the attributes to elements. I've put a variety of node paths in place of the */# match, but then I get nothing back, so that's clearly wrong.
Apologies in advance if this is not clear. I haven't worked with XSLT for quite a few years.
Niether your stylesheet it's complete nor your output it's well explained, but for transforming attibutes into elements you could a transformation similar to this:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:d="_x0031_4Q_CSV">
<xsl:template match="node()|#*">
<xsl:copy>
<xsl:apply-templates select="node()|#*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="d:Detail">
<xsl:variable name="white-list" select="#ID_RSSD|#D_DT|#CQSCS383|#Transtype"/>
<xsl:copy>
<xsl:apply-templates select="$white-list"/>
<xsl:apply-templates select="#*[count(.|$white-list)!=count($white-list)]"
mode="element"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="#*" mode="element">
<xsl:element name="{name()}">
<xsl:value-of
select="."/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Output:
<Report xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="_x0031_4Q_CSV"
xsi:schemaLocation="_x0031_4Q_CSV http://MySSRSServer/ReportServer?%2FTRR%20Reports%2F14Q_CSV&rs%3ACommand=Render&rs%3AFormat=XML&rs%3ASessionID=uuurm045z4bsq2maejbbb045&rc%3ASchema=True"
Name="14Q_CSV"
textbox1="14Q_CSV Period:201711 Publish Date: 12/7/2017 4:38:49 PM">
<table1>
<Detail_Collection>
<Detail ID_RSSD="1037003"
D_DT="2017-11-30T00:00:00"
CQSCS383="S0004260053"
Transtype="I">
<CQSCF841 xmlns="">2020-01-23T00:00:00</CQSCF841>
<CQSCP082 xmlns="">CUSIP</CQSCP082>
<CQSCP083 xmlns="">31384YCC8</CQSCP083>
<CQSCS370 xmlns="">N</CQSCS370>
<CQSCP084 xmlns="">Agency MBS</CQSCP084>
<CQSCP085 xmlns="">FN 537467</CQSCP085>
<CQSCP087 xmlns="">50768.00</CQSCP087>
<CQSCP088 xmlns="">53330.00</CQSCP088>
<CQSCP089 xmlns="">50667.00</CQSCP089>
<CQSCP090 xmlns="">12484343.00</CQSCP090>
<CQSCP091 xmlns="">0.00</CQSCP091>
<CQSCP092 xmlns="">AFS</CQSCP092>
<CQSCP093 xmlns="">2017-11-30T00:00:00</CQSCP093>
<CQSCP094 xmlns="">0.070363000000</CQSCP094>
<CQSCP095 xmlns="">2000-04-01T00:00:00</CQSCP095>
<CQSCS371 xmlns="">USD</CQSCS371>
<CQSCHK21 xmlns="">105.2563040000</CQSCHK21>
</Detail>
<Detail ID_RSSD="1037003"
D_DT="2017-11-30T00:00:00"
CQSCS383="S0004260054"
Transtype="I">
<CQSCF841 xmlns="">2020-01-23T00:00:00</CQSCF841>
<CQSCP082 xmlns="">CUSIP</CQSCP082>
<CQSCP083 xmlns="">31384YCD6</CQSCP083>
<CQSCS370 xmlns="">N</CQSCS370>
<CQSCP084 xmlns="">Agency MBS</CQSCP084>
<CQSCP085 xmlns="">FN 537468</CQSCP085>
<CQSCP087 xmlns="">96069.00</CQSCP087>
<CQSCP088 xmlns="">106433.00</CQSCP088>
<CQSCP089 xmlns="">96069.00</CQSCP089>
<CQSCP090 xmlns="">12066524.00</CQSCP090>
<CQSCP091 xmlns="">0.00</CQSCP091>
<CQSCP092 xmlns="">AFS</CQSCP092>
<CQSCP093 xmlns="">2017-11-30T00:00:00</CQSCP093>
<CQSCP094 xmlns="">0.067115000000</CQSCP094>
<CQSCP095 xmlns="">2000-04-01T00:00:00</CQSCP095>
<CQSCS371 xmlns="">USD</CQSCS371>
<CQSCHK21 xmlns="">110.7884470000</CQSCHK21>
</Detail>
<Detail ID_RSSD="1037003"
D_DT="2017-11-30T00:00:00"
CQSCS383="S0004260057"
Transtype="I">
<CQSCF841 xmlns="">2020-01-23T00:00:00</CQSCF841>
<CQSCP082 xmlns="">CUSIP</CQSCP082>
<CQSCP083 xmlns="">31384YCH7</CQSCP083>
<CQSCS370 xmlns="">N</CQSCS370>
<CQSCP084 xmlns="">Agency MBS</CQSCP084>
<CQSCP085 xmlns="">FN 537472</CQSCP085>
<CQSCP087 xmlns="">133804.00</CQSCP087>
<CQSCP088 xmlns="">151158.00</CQSCP088>
<CQSCP089 xmlns="">134964.00</CQSCP089>
<CQSCP090 xmlns="">6415504.00</CQSCP090>
<CQSCP091 xmlns="">0.00</CQSCP091>
<CQSCP092 xmlns="">AFS</CQSCP092>
<CQSCP093 xmlns="">2017-11-30T00:00:00</CQSCP093>
<CQSCP094 xmlns="">0.064967000000</CQSCP094>
<CQSCP095 xmlns="">2000-04-01T00:00:00</CQSCP095>
<CQSCS371 xmlns="">USD</CQSCS371>
<CQSCHK21 xmlns="">111.9988700000</CQSCHK21>
</Detail>
<Detail ID_RSSD="1037003"
D_DT="2017-11-30T00:00:00"
CQSCS383="S0004260058"
Transtype="I">
<CQSCF841 xmlns="">2020-01-23T00:00:00</CQSCF841>
<CQSCP082 xmlns="">CUSIP</CQSCP082>
<CQSCP083 xmlns="">31384YCJ3</CQSCP083>
<CQSCS370 xmlns="">N</CQSCS370>
<CQSCP084 xmlns="">Agency MBS</CQSCP084>
<CQSCP085 xmlns="">FN 537473</CQSCP085>
<CQSCP087 xmlns="">188500.00</CQSCP087>
<CQSCP088 xmlns="">198238.00</CQSCP088>
<CQSCP089 xmlns="">186974.00</CQSCP089>
<CQSCP090 xmlns="">7054878.00</CQSCP090>
<CQSCP091 xmlns="">0.00</CQSCP091>
<CQSCP092 xmlns="">AFS</CQSCP092>
<CQSCP093 xmlns="">2017-11-30T00:00:00</CQSCP093>
<CQSCP094 xmlns="">0.074321000000</CQSCP094>
<CQSCP095 xmlns="">2000-04-01T00:00:00</CQSCP095>
<CQSCS371 xmlns="">USD</CQSCS371>
<CQSCHK21 xmlns="">106.0240080000</CQSCHK21>
</Detail>
<Detail ID_RSSD="1037003"
D_DT="2017-11-30T00:00:00"
CQSCS383="S0004260059"
Transtype="I">
<CQSCF841 xmlns="">2020-01-23T00:00:00</CQSCF841>
<CQSCP082 xmlns="">CUSIP</CQSCP082>
<CQSCP083 xmlns="">31384YCK0</CQSCP083>
<CQSCS370 xmlns="">N</CQSCS370>
<CQSCP084 xmlns="">Agency MBS</CQSCP084>
<CQSCP085 xmlns="">FN 537474</CQSCP085>
<CQSCP087 xmlns="">53662.00</CQSCP087>
<CQSCP088 xmlns="">56159.00</CQSCP088>
<CQSCP089 xmlns="">52828.00</CQSCP089>
<CQSCP090 xmlns="">6033726.00</CQSCP090>
<CQSCP091 xmlns="">0.00</CQSCP091>
<CQSCP092 xmlns="">AFS</CQSCP092>
<CQSCP093 xmlns="">2017-11-30T00:00:00</CQSCP093>
<CQSCP094 xmlns="">0.079403000000</CQSCP094>
<CQSCP095 xmlns="">2000-04-01T00:00:00</CQSCP095>
<CQSCS371 xmlns="">USD</CQSCS371>
<CQSCHK21 xmlns="">106.3062160000</CQSCHK21>
</Detail>
<Detail ID_RSSD="1037003"
D_DT="2017-11-30T00:00:00"
CQSCS383="S0004260060"
Transtype="I">
<CQSCF841 xmlns="">2020-01-23T00:00:00</CQSCF841>
<CQSCP082 xmlns="">CUSIP</CQSCP082>
<CQSCP083 xmlns="">31384YCL8</CQSCP083>
<CQSCS370 xmlns="">N</CQSCS370>
<CQSCP084 xmlns="">Agency MBS</CQSCP084>
<CQSCP085 xmlns="">FN 537475</CQSCP085>
<CQSCP087 xmlns="">53958.00</CQSCP087>
<CQSCP088 xmlns="">57002.00</CQSCP088>
<CQSCP089 xmlns="">53518.00</CQSCP089>
<CQSCP090 xmlns="">5710436.00</CQSCP090>
<CQSCP091 xmlns="">0.00</CQSCP091>
<CQSCP092 xmlns="">AFS</CQSCP092>
<CQSCP093 xmlns="">2017-11-30T00:00:00</CQSCP093>
<CQSCP094 xmlns="">0.076705000000</CQSCP094>
<CQSCP095 xmlns="">2000-04-01T00:00:00</CQSCP095>
<CQSCS371 xmlns="">USD</CQSCS371>
<CQSCHK21 xmlns="">106.5098890000</CQSCHK21>
</Detail>
</Detail_Collection>
</table1>
</Report>
Do note: attributes should be output before any other node type, Kaysian method for exclusion.

Overwrite an existing text file c++

This is how my Save As works - it is copying the current file's lines until it reaches the first figure and then I use my print methods to print the figure's info and then close the tag.
std::ofstream newFile(filePath1_fixed, std::ios::app);
std::fstream openedFile(filePath);
std::string line1;
while (std::getline(openedFile, line1)) {
if (line1.find("<rect") != std::string::npos
|| line1.find("<circle") != std::string::npos
|| line1.find("<line") != std::string::npos)
break;
newFile << line1 << std::endl;
}
figc.printToFile(newFile);
newFile << "</svg>\n";
My question is how to save the changes to the current file? I tried something like this:
std::ifstream openedFile(filePath);
std::ofstream newFile(filePath, std::ios::app);
std::string line1;
std::string info_beg[100];
int t = 0;
while (std::getline(openedFile, line1)) {
std::cout << "HELLYEAH";
if (line1.find("<rect") != std::string::npos
|| line1.find("<circle") != std::string::npos
|| line1.find("<line") != std::string::npos)
break;
info_beg[t++] = line1;
}
for (int i = 0; i < t; i++)
newFile << info_beg[i] << std::endl;
figc.printToFile(newFile);
newFile << "</svg>\n";
This is the nearest I've gone. I get this:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="12cm" height="4cm" viewBox="0 0 1200 400"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<desc>Example rect01 - rectangle with sharp corners</desc>
<!-- Show outline of canvas using 'rect' element -->
<rect x="1" y="1" width="1198" height="398"
fill="none" stroke="blue" stroke-width="2" />
<line x1="20" y1="100" x2="100" y2="20"
stroke="red" stroke-width="2" />
<rect x="20" y="30" width="40" height="50"
fill="red" stroke="red" stroke-width="1" />
<rect x="10" y="20" width="30" height="40"
fill="red" stroke="blue" stroke-width="1" />
<line x1="100" y1="200" x2="300" y2="400"
stroke="red" stroke-width="2" />
<circle cx="10" cy="20" r="30"
fill="red" stroke="blue" stroke-width="2" />
</svg>
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="12cm" height="4cm" viewBox="0 0 1200 400"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<desc>Example rect01 - rectangle with sharp corners</desc>
<!-- Show outline of canvas using 'rect' element -->
<rect x="1" y="1" width="1198" height="398"
fill="none" stroke="blue" stroke-width="2" />
<line x1="20" y1="100" x2="100" y2="20"
stroke="red" stroke-width="2" />
<rect x="20" y="30" width="40" height="50"
fill="red" stroke="red" stroke-width="1" />
<rect x="10" y="20" width="30" height="40"
fill="red" stroke="blue" stroke-width="1" />
<line x1="100" y1="200" x2="300" y2="400"
stroke="red" stroke-width="2" />
<circle cx="10" cy="20" r="30"
fill="red" stroke="blue" stroke-width="2" />
<rect x="10" y="20" width="30" height="40"
fill="red" stroke="blue" stroke-width="2" />
</svg>
So my actual question is how to delete the first or overwrite it or I need a different approach.
Use ios::trunc instead of ios::app
Using std::ios::app in the constructor for your std::ofstream tells the program to append to the file and not overwrite it. If you want to overwrite it (ie truncate), then using std::ios::trunc will tell the program to overwrite the existing file. ofstream does this by default, so you could just write the initialization as just std::ofstream newFile(filePath);.
Also, don't try to read the file and write to it at the same time; that won't work. Use ifstream to get the data into the buffer, then use close() to close the file. Then initialize newFile to overwrite the file and write out the buffer.

How to get the namespace, method, soap_action from a wsdl file

I have a WSDL file that displayed below :
<wsdl:definitions targetNamespace="urn:sap-com:document:sap:rfc:functions"><wsdl:documentation><sidl:sidl/></wsdl:documentation><wsp:UsingPolicy wsdl:required="true"/><wsp:Policy wsu:Id="BN__binding"><wsp:ExactlyOne><wsp:All><sapattahnd:Enabled>false</sapattahnd:Enabled><saptrnbnd:OptimizedMimeSerialization wsp:Optional="true"/><wsaw:UsingAddressing wsp:Optional="true"/><wsp:All><sp:TransportBinding><wsp:Policy><sp:TransportToken><wsp:Policy><sp:HttpsToken><wsp:Policy><sp:HttpBasicAuthentication/></wsp:Policy></sp:HttpsToken></wsp:Policy></sp:TransportToken><sp:AlgorithmSuite><wsp:Policy><sp:Basic128Rsa15/></wsp:Policy></sp:AlgorithmSuite><sp:Layout><wsp:Policy><sp:Strict/></wsp:Policy></sp:Layout></wsp:Policy></sp:TransportBinding></wsp:All></wsp:All><wsp:All><sapattahnd:Enabled>false</sapattahnd:Enabled><saptrnbnd:OptimizedXMLTransfer uri="http://xml.sap.com/2006/11/esi/esp/binxml" wsp:Optional="true"/><wsaw:UsingAddressing wsp:Optional="true"/><wsp:All><sp:TransportBinding><wsp:Policy><sp:TransportToken><wsp:Policy><sp:HttpsToken><wsp:Policy><sp:HttpBasicAuthentication/></wsp:Policy></sp:HttpsToken></wsp:Policy></sp:TransportToken><sp:AlgorithmSuite><wsp:Policy><sp:Basic128Rsa15/></wsp:Policy></sp:AlgorithmSuite><sp:Layout><wsp:Policy><sp:Strict/></wsp:Policy></sp:Layout></wsp:Policy></sp:TransportBinding></wsp:All></wsp:All></wsp:ExactlyOne></wsp:Policy><wsp:Policy wsu:Id="BN__binding_soap12"><wsp:ExactlyOne><wsp:All><sapattahnd:Enabled>false</sapattahnd:Enabled><saptrnbnd:OptimizedMimeSerialization wsp:Optional="true"/><wsaw:UsingAddressing wsp:Optional="true"/><wsp:All><sp:TransportBinding><wsp:Policy><sp:TransportToken><wsp:Policy><sp:HttpsToken><wsp:Policy><sp:HttpBasicAuthentication/></wsp:Policy></sp:HttpsToken></wsp:Policy></sp:TransportToken><sp:AlgorithmSuite><wsp:Policy><sp:Basic128Rsa15/></wsp:Policy></sp:AlgorithmSuite><sp:Layout><wsp:Policy><sp:Strict/></wsp:Policy></sp:Layout></wsp:Policy></sp:TransportBinding></wsp:All></wsp:All><wsp:All><sapattahnd:Enabled>false</sapattahnd:Enabled><saptrnbnd:OptimizedXMLTransfer uri="http://xml.sap.com/2006/11/esi/esp/binxml" wsp:Optional="true"/><wsaw:UsingAddressing wsp:Optional="true"/><wsp:All><sp:TransportBinding><wsp:Policy><sp:TransportToken><wsp:Policy><sp:HttpsToken><wsp:Policy><sp:HttpBasicAuthentication/></wsp:Policy></sp:HttpsToken></wsp:Policy></sp:TransportToken><sp:AlgorithmSuite><wsp:Policy><sp:Basic128Rsa15/></wsp:Policy></sp:AlgorithmSuite><sp:Layout><wsp:Policy><sp:Strict/></wsp:Policy></sp:Layout></wsp:Policy></sp:TransportBinding></wsp:All></wsp:All></wsp:ExactlyOne></wsp:Policy><wsp:Policy wsu:Id="IF__ztm_ws_get_emp_holidays"><wsp:ExactlyOne><wsp:All><sapsession:Session><sapsession:enableSession>false</sapsession:enableSession></sapsession:Session><sapcentraladmin:CentralAdministration wsp:Optional="true"><sapcentraladmin:BusinessApplicationID>005056AC6E191ED3979A90345DADF406</sapcentraladmin:BusinessApplicationID></sapcentraladmin:CentralAdministration></wsp:All></wsp:ExactlyOne></wsp:Policy><wsp:Policy wsu:Id="OP__Z_TM_ETM_GET_EMPL_HOLIDAYS"><wsp:ExactlyOne><wsp:All><saptrhnw05:required>no</saptrhnw05:required><sapcomhnd:enableCommit>false</sapcomhnd:enableCommit><sapblock:enableBlocking>true</sapblock:enableBlocking><saprmnw05:enableWSRM>false</saprmnw05:enableWSRM></wsp:All></wsp:ExactlyOne></wsp:Policy><wsdl:types><xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions"><xsd:simpleType name="char1"><xsd:restriction base="xsd:string"><xsd:maxLength value="1"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="char10"><xsd:restriction base="xsd:string"><xsd:maxLength value="10"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="char20"><xsd:restriction base="xsd:string"><xsd:maxLength value="20"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="char220"><xsd:restriction base="xsd:string"><xsd:maxLength value="220"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="char30"><xsd:restriction base="xsd:string"><xsd:maxLength value="30"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="char32"><xsd:restriction base="xsd:string"><xsd:maxLength value="32"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="char40"><xsd:restriction base="xsd:string"><xsd:maxLength value="40"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="char50"><xsd:restriction base="xsd:string"><xsd:maxLength value="50"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="date10"><xsd:restriction base="xsd:string"><xsd:maxLength value="10"/><xsd:pattern value="\d\d\d\d-\d\d-\d\d"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="numeric3"><xsd:restriction base="xsd:string"><xsd:maxLength value="3"/><xsd:pattern value="\d*"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="numeric6"><xsd:restriction base="xsd:string"><xsd:maxLength value="6"/><xsd:pattern value="\d*"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="numeric8"><xsd:restriction base="xsd:string"><xsd:maxLength value="8"/><xsd:pattern value="\d*"/></xsd:restriction></xsd:simpleType><xsd:complexType name="ZTMSHOLIDAYS"><xsd:sequence><xsd:element name="DATE" type="tns:date10"/><xsd:element name="DESCRIPTION" type="tns:char40"/></xsd:sequence></xsd:complexType><xsd:complexType name="BAPIRET2"><xsd:sequence><xsd:element name="TYPE" type="tns:char1"/><xsd:element name="ID" type="tns:char20"/><xsd:element name="NUMBER" type="tns:numeric3"/><xsd:element name="MESSAGE" type="tns:char220"/><xsd:element name="LOG_NO" type="tns:char20"/><xsd:element name="LOG_MSG_NO" type="tns:numeric6"/><xsd:element name="MESSAGE_V1" type="tns:char50"/><xsd:element name="MESSAGE_V2" type="tns:char50"/><xsd:element name="MESSAGE_V3" type="tns:char50"/><xsd:element name="MESSAGE_V4" type="tns:char50"/><xsd:element name="PARAMETER" type="tns:char32"/><xsd:element name="ROW" type="xsd:int"/><xsd:element name="FIELD" type="tns:char30"/><xsd:element name="SYSTEM" type="tns:char10"/></xsd:sequence></xsd:complexType><xsd:complexType name="ZTMTT_HOLIDAYS"><xsd:sequence><xsd:element name="item" type="tns:ZTMSHOLIDAYS" minOccurs="0" maxOccurs="unbounded"/></xsd:sequence></xsd:complexType><xsd:element name="Z_TM_ETM_GET_EMPL_HOLIDAYS"><xsd:complexType><xsd:sequence><xsd:element name="PI_PERNR" type="tns:numeric8"/></xsd:sequence></xsd:complexType></xsd:element><xsd:element name="Z_TM_ETM_GET_EMPL_HOLIDAYSResponse"><xsd:complexType><xsd:sequence><xsd:element name="PE_I_HOLIDAYS" type="tns:ZTMTT_HOLIDAYS"/><xsd:element name="PE_MESSAGE" type="tns:BAPIRET2"/></xsd:sequence></xsd:complexType></xsd:element></xsd:schema></wsdl:types><wsdl:message name="Z_TM_ETM_GET_EMPL_HOLIDAYS"><wsdl:part name="parameters" element="tns:Z_TM_ETM_GET_EMPL_HOLIDAYS"/></wsdl:message><wsdl:message name="Z_TM_ETM_GET_EMPL_HOLIDAYSResponse"><wsdl:part name="parameter" element="tns:Z_TM_ETM_GET_EMPL_HOLIDAYSResponse"/></wsdl:message><wsdl:portType name="ztm_ws_get_emp_holidays"><wsp:Policy><wsp:PolicyReference URI="#IF__ztm_ws_get_emp_holidays"/></wsp:Policy><wsdl:operation name="Z_TM_ETM_GET_EMPL_HOLIDAYS"><wsp:Policy><wsp:PolicyReference URI="#OP__Z_TM_ETM_GET_EMPL_HOLIDAYS"/></wsp:Policy><wsdl:input message="tns:Z_TM_ETM_GET_EMPL_HOLIDAYS"/><wsdl:output message="tns:Z_TM_ETM_GET_EMPL_HOLIDAYSResponse"/></wsdl:operation></wsdl:portType><wsdl:binding name="binding" type="tns:ztm_ws_get_emp_holidays"><wsp:Policy><wsp:PolicyReference URI="#BN__binding"/></wsp:Policy><soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/><wsdl:operation name="Z_TM_ETM_GET_EMPL_HOLIDAYS"><soap:operation soapAction="urn:sap-com:document:sap:rfc:functions:ztm_ws_get_emp_holidays:Z_TM_ETM_GET_EMPL_HOLIDAYSRequest" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input><wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:binding name="binding_soap12" type="tns:ztm_ws_get_emp_holidays"><wsp:Policy><wsp:PolicyReference URI="#BN__binding_soap12"/></wsp:Policy><wsoap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/><wsdl:operation name="Z_TM_ETM_GET_EMPL_HOLIDAYS"><wsoap12:operation soapAction="urn:sap-com:document:sap:rfc:functions:ztm_ws_get_emp_holidays:Z_TM_ETM_GET_EMPL_HOLIDAYSRequest" style="document"/><wsdl:input><wsoap12:body use="literal"/></wsdl:input><wsdl:output><wsoap12:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="OfficialHolidays"><wsdl:port name="binding" binding="tns:binding"><soap:address location="http://unrwa-red-71.unrwa.org:8000/sap/bc/srt/rfc/sap/ztm_ws_get_emp_holidays/520/officialholidays/binding"/></wsdl:port><wsdl:port name="binding_soap12" binding="tns:binding_soap12"><wsoap12:address location="http://unrwa-red-71.unrwa.org:8000/sap/bc/srt/rfc/sap/ztm_ws_get_emp_holidays/520/officialholidays/binding"/></wsdl:port></wsdl:service></wsdl:definitions>
I want to know these values form it:
namespace
soap action
method name
what are they ?
definitions targetNamespace="http://worldheritage.org/"
so your name space is
NameSpace = urn:sap-com:document:sap:rfc:functions
operation name="YourMethodName"
and method name is
method name="Z_TM_ETM_GET_EMPL_HOLIDAYS
Server URL is
soap:address location="http://unrwa-red-71.unrwa.org:8000/sap/bc/srt/rfc/sap/ztm_ws_get_emp_holidays/520/officialholidays/binding"

Problems with xml parsing using tiny xml in c++?

I am trying to parse the following xml using tiny xml parser.I am trying to get the value of all producer and consumer attributes of q2channel tag in the xml file.I am using tinyxml2.
So far I have written the following code but I am stuck here as when I try to print something I get null.
XMLDocument doc;
bool loadOkay=doc.LoadFile( "resources/q2profiling.xml" );
XMLElement* titleElement = doc.FirstChildElement()->FirstChildElement();
const char* title = titleElement->GetText();
printf( "The remaining xml is %s\n", title );
I have tried several different variations of the code to progress my work but I am stuck here.Please help me in printing the value of all consumer and producer attributes of q2channel tag from the xml.
The xml file is given below
<
?xml version="1.0" encoding="UTF-8" ?>
<q2:profiles xmlns:q2="http://www.example.org/q2profiling" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/q2profiling q2profiling.xsd">
<q2:application name="testAPPlication">
<q2:QDUGraph>
<q2:channel producer="UNKNOWN_PRODUCER(CONSTANT_DATA)" consumer="Out_of_the_main_function_scope">
<q2:UnMA>19298</q2:UnMA>
<q2:Bytes>25892</q2:Bytes>
<q2:UnDV>19298</q2:UnDV>
<q2:UnMARanges>
<q2:range lower="134512692" upper="134512695" />
<q2:range lower="134512700" upper="134512703" />
</q2:UnMARanges>
</q2:channel>
<q2:channel producer="UNKNOWN_PRODUCER(CONSTANT_DATA)" consumer="main">
<q2:UnMA>160</q2:UnMA>
<q2:Bytes>234</q2:Bytes>
<q2:UnDV>160</q2:UnDV>
<q2:UnMARanges>
<q2:range lower="134513084" upper="134513087" />
<q2:range lower="134513116" upper="134513119" />
<q2:range lower="134513129" upper="134513129" />
</q2:UnMARanges>
</q2:channel>
<q2:channel producer="Out_of_the_main_function_scope" consumer="Out_of_the_main_function_scope">
<q2:UnMA>1474</q2:UnMA>
<q2:Bytes>14815</q2:Bytes>
<q2:UnDV>2468</q2:UnDV>
<q2:UnMARanges>
<q2:range lower="134520828" upper="134520831" />
<q2:range lower="134520836" upper="134520843" />
<q2:range lower="3077693172" upper="3077693175" />
</q2:UnMARanges>
</q2:channel>
<q2:channel producer="Out_of_the_main_function_scope" consumer="main">
<q2:UnMA>209</q2:UnMA>
<q2:Bytes>381</q2:Bytes>
<q2:UnDV>209</q2:UnDV>
<q2:UnMARanges>
<q2:range lower="134520836" upper="134520847" />
<q2:range lower="3045611784" upper="3045611795" />
</q2:UnMARanges>
</q2:channel>
<q2:channel producer="main" consumer="Out_of_the_main_function_scope">
<q2:UnMA>40</q2:UnMA>
<q2:Bytes>60</q2:Bytes>
<q2:UnDV>40</q2:UnDV>
<q2:UnMARanges>
<q2:range lower="3048639008" upper="3048639019" />
<q2:range lower="3048639024" upper="3048639031" />
</q2:UnMARanges>
</q2:channel>
<q2:channel producer="main" consumer="main">
<q2:UnMA>32</q2:UnMA>
<q2:Bytes>444</q2:Bytes>
<q2:UnDV>88</q2:UnDV>
<q2:UnMARanges>
<q2:range lower="3048639008" upper="3048639011" />
<q2:range lower="3048639016" upper="3048639019" />
</q2:UnMARanges>
</q2:channel>
<q2:channel producer="UNKNOWN_PRODUCER(CONSTANT_DATA)" consumer="sum">
<q2:UnMA>1</q2:UnMA>
<q2:Bytes>1000</q2:Bytes>
<q2:UnDV>1</q2:UnDV>
<q2:UnMARanges>
<q2:range lower="134520860" upper="134520860" />
</q2:UnMARanges>
</q2:channel>
<q2:channel producer="UNKNOWN_PRODUCER(CONSTANT_DATA)" consumer="diff">
<q2:UnMA>1</q2:UnMA>
<q2:Bytes>1000</q2:Bytes>
<q2:UnDV>1</q2:UnDV>
<q2:UnMARanges>
<q2:range lower="134520860" upper="134520860" />
</q2:UnMARanges>
</q2:channel>
<q2:channel producer="init" consumer="sum">
<q2:UnMA>2000</q2:UnMA>
<q2:Bytes>2000</q2:Bytes>
<q2:UnDV>2000</q2:UnDV>
<q2:UnMARanges>
<q2:range lower="134520896" upper="134521895" />
<q2:range lower="134523968" upper="134524967" />
</q2:UnMARanges>
</q2:channel>
<q2:channel producer="init" consumer="diff">
<q2:UnMA>2000</q2:UnMA>
<q2:Bytes>2000</q2:Bytes>
<q2:UnDV>2000</q2:UnDV>
<q2:UnMARanges>
<q2:range lower="134520896" upper="134521895" />
<q2:range lower="134523968" upper="134524967" />
</q2:UnMARanges>
</q2:channel>
</q2:QDUGraph>
</q2:application>
</q2:profiles>
The function GetText() won't give you the actual name of the node in question, but the text inside the node. For instance, invoking GetText() on this hypothetical node
<node>This is text!</node>
will yield "This is text!" as a const char* or a const std::string& depending on how you compile. See the API reference of TiXmlElement.
If you want to query the node name itself, use TiXmlNode::Value().
If you want an attribute, simply use Attribute(const char*) or QueryStringAttribute(...) on the element. For instance, retrieving and printing the following with the document you provided
std::cout << doc.FirstChildElement ()->FirstChildElement ()->Attribute ("name") << std::endl;
yields "testAPPlication".
In general, see the full documentation of TinyXML first.
EDIT: The following example depicts in a simple, yet ugly way what you need:
TiXmlDocument doc;
if(doc.LoadFile ("test.xml"))
{
TiXmlElement* graphElem = doc.FirstChildElement()->FirstChildElement ()->FirstChildElement ();
TiXmlElement* channelElem = graphElem->FirstChildElement ();
for(; channelElem; channelElem = channelElem->NextSiblingElement ())
{
std::cout << channelElem->Attribute ("producer")
<< " | "
<< channelElem->Attribute ("consumer")
<< std::endl;
}
}
EDIT2: Removed infinite loop and conditional.