0

Hello all!
I'm very much a noob to c#... and programming for that matter... and xml! So, I'm having troubles with a project that I'm working on that I hope someone here can help me with.

I wish to search through an xml file that is generated by a Share Trading program - the search is for a particular attribute (TOOLNAME="U3RvcH==") and then I want to read the 'value' that follows (VALUES="A|0|5.31156|B|0|40129.776606555|C|0|595.96808665;A|1|5.31156|B|1|40177.8112681687|C|1|602.83018117") - this represents a horizontal line placed at [A]$5.31156 the & [C] components are the xy positions of the start and finish of the line. I am only interested in the A component of the Value.

The only constant accross any number of charts will be the TOOLNAME - so I need to search for that and then get only the 'A' portion of the Value. How do I go about this? Its got me completely stumped!

Thanks in advance!

Attachments
<WORKBOOK VERSION="5" ACTIVEPAGE="0" PRIMARYITEM="0" >
<PAGE NAME="AMP" PRIMARYITEM="0" COLOR="16711680" DOCKED="1" PAGECOORDS=" PERCTLEFT|54.0;PERCTTOP|125.0;PERCTWIDTH|1642.0;PERCTHEIGHT|928.0" IMAGEINDEX="12" PAGECOLOUR="0" TRAINON="0" >
<CHART PRIMARYITEM="0" CHARTCOORDS=" PERCTLEFT|0.0;PERCTTOP|0.0;PERCTWIDTH|100.0;PERCTHEIGHT|100.0" BACKGROUNDCOL="16777215" CHARTTITLE="" CALENDAR="0" SHOWBLANKS="0" IGNOREDILUTIONS="0" SHOWRIGHTSCALE="1" SHOWLEFTSCALE="0" SHOWINFOPANEL="1" LOCKPAGEUPDATE="0" DISPLAYTYPE="1" GLOBALDSPTYPE="0" BLANKBARS="100" WALLCHARTMODE="0" MILSPERBAR="8.0" MILSPERMOVE="8.0" MOVESIZE="0.01" LOCKPRICERATIO="0" PRICERATIO="0.08770426" HYPOTHESIZER="0" EDITMODE="0" FUTURECOLOUR="16711935" TRAINWATERMARK="1" SHOWFLOATTITLE="0" LAYERSETTING="MT0xfDExPTF8MTExPTF8MTEyPTE=" INVERTED="0" RCCSTARTDATE="39780" >
<VIEW PRIMARYITEM="1" VIEWCOORDS=" PERCTLEFT|0.0;PERCTTOP|0.0;PERCTWIDTH|100.0;PERCTHEIGHT|100.0" ZOOMVIEWDIMS=" PERCTLEFT|0.0;PERCTTOP|0.0;PERCTWIDTH|100.0;PERCTHEIGHT|100.0" GUIVIEWHEIGHT="50.0" DISPLAYBARS="87" LOGARITHMIC="0" >
<LAYER PRIMARYITEM="1" LAYERNAME="TGF5ZXJ=" MAJORDATESCALESTEP="20" MINORDATESCALESTEP="1" SCALETYPE="0" AUTOMAX="1" SCALEMAX="7.93" AUTOMIN="1" SCALEMIN="3.52" AUTORANGE="1" SCALERNG="4.41" AUTOPRICESTEP="1" MINORSCALESTEP="0.01" MAJORSCALESTEP="20" AUTOSCALESTARTPRICE="1" SCALESTARTPRICE="0.0" AUTOSCALESTARTDATE="1" SCALESTARTDATE="40145" SCALESPERLABEL="10" LOCKED="1" VISIBLE="1" OPACITY="255" LAYERLINKED="1" SHOWDEPTH="1" DEPTHLEVEL="1" SHOWRIGHTSCALE="1" SHOWLEFTSCALE="0" INVERTED="0" >
<TOOLITEM TIMEFRAME="1 Week (Alt+2)" STYLE="Bar Chart" PRIMARYITEM="1" BARWIDTH="1" CSCHEME="4" CSTRONG="16711680" CWEAK="255" STYLEID="1" DATATOLOAD="0" DATETOLOADFROM="0" DATETOLOADTO="0" C50MARK="32768" LABELS="DATELABEL=1| CALENDARLABEL=1| BARSLABEL=1| PRICELABEL=1|" PLOT0="0" TRANS="255" VISIBLE="1" ALLOWHIDECHILD="1" SYMBOLFLOATPOS="50.0" TOOLID="Chart">
<DATAFILE CODE="AMP" PRODUCTID="1" FILENAME="AMP.M4D" MERGE="4">
</DATAFILE>
</TOOLITEM>
</LAYER>
<LAYER PRIMARYITEM="0" LAYERNAME="TGF5ZXJ=" MAJORDATESCALESTEP="20" MINORDATESCALESTEP="1" SCALETYPE="0" AUTOMAX="1" SCALEMAX="7.93" AUTOMIN="1" SCALEMIN="3.52" AUTORANGE="1" SCALERNG="4.41" AUTOPRICESTEP="1" MINORSCALESTEP="0.01" MAJORSCALESTEP="20" AUTOSCALESTARTPRICE="1" SCALESTARTPRICE="0.0" AUTOSCALESTARTDATE="1" SCALESTARTDATE="40145" SCALESPERLABEL="10" LOCKED="1" VISIBLE="1" OPACITY="255" LAYERLINKED="1" SHOWDEPTH="1" DEPTHLEVEL="1" SHOWRIGHTSCALE="0" SHOWLEFTSCALE="0" INVERTED="0" >
<TOOLITEM PRIMARYITEM="0" EXTSTART="0" EXTEND="0" LINE="A|2;B|1;C|33023" DATASOURCE="0" TOOLNAME="VHJlbmQgTGluZW==" VALUES="A|0|10.97000|B|0|39367|C|0|487.0;A|1|6.39195|B|1|40207|C|1|607.0" LOGADJ="0" TRANS="218" VISIBLE="1" ALLOWHIDECHILD="0" SYMBOLFLOATPOS="50.0" TOOLID="MASTL">
</TOOLITEM>
<TOOLITEM PRIMARYITEM="0" EXTSTART="0" EXTEND="0" LINE="A|0;B|1;C|32768" DATASOURCE="0" TOOLNAME="VHJlbmQgTGluZW==" VALUES="A|0|3.52000|B|0|39885|C|0|561.0;A|1|5.98438|B|1|40165|C|1|601.0" LOGADJ="0" TRANS="255" VISIBLE="1" ALLOWHIDECHILD="0" SYMBOLFLOATPOS="50.0" TOOLID="MASTL">
</TOOLITEM>
<TOOLITEM PRIMARYITEM="0" BANDSIZE="5.0" FILLTRANS="116" FILLCOLOUR="32512" LINE="A|0;B|1;C|0" DATASOURCE="0" TOOLNAME="VHJlbmQgQmFuZG==" VALUES="A|0|3.52000|B|0|39885|C|0|561.0;A|1|6.23081|B|1|40193|C|1|605.0" LOGADJ="0" TRANS="86" VISIBLE="1" ALLOWHIDECHILD="0" SYMBOLFLOATPOS="50.0" TOOLID="MASTB">
</TOOLITEM>
<TOOLITEM PRIMARYITEM="0" EXTSTART="0" EXTEND="0" LINE="A|2;B|2;C|204" SHOWPRICE="1" FONTSIZE="10" FONT="MS Sans Serif, 8, [], [$000000CC]" TEXTPOS="2" AUTOLINESIZE="0" DATASOURCE="0" TOOLNAME="U3RvcH==" VALUES="A|0|5.31156|B|0|40116|C|0|594.0;A|1|5.31156|B|1|40177.8112681687|C|1|602.83018117" LOGADJ="0" TRANS="255" VISIBLE="1" ALLOWHIDECHILD="0" SYMBOLFLOATPOS="50.0" TOOLID="MASHL">
</TOOLITEM>
</LAYER>
</VIEW>
</CHART>
</PAGE>
</WORKBOOK>
2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by kobalt
0

Use XPath,

XPathDocument dc = new XPathDocument(@"file.xml");
    XPathNavigator nav = dc.CreateNavigator();

   XPathNodeIterator i = nav.Select("//WORKBOOK/PAGE/CHART/VIEW/LAYER/TOOLITEM[@TOOLNAME='U3RvcH==']");

   while (i.MoveNext()){
      string val=i.Current.GetAttribute("VALUES", "");
   }
0

Use XPath,

XPathDocument dc = new XPathDocument(@"file.xml");
    XPathNavigator nav = dc.CreateNavigator();

   XPathNodeIterator i = nav.Select("//WORKBOOK/PAGE/CHART/VIEW/LAYER/TOOLITEM[@TOOLNAME='U3RvcH==']");

   while (i.MoveNext()){
      string val=i.Current.GetAttribute("VALUES", "");
   }

Thanks - that worked great! I worked out that if I added:

string s = val.Substring(4, 7)

I can get the exact figure I'm after!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.