3 Replies - 2736 Views - Last Post: 02 July 2009 - 08:10 AM Rate Topic: -----

#1 izzahaf  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 112
  • Joined: 12-March 09

get double value with comma in xml file

Posted 01 July 2009 - 08:31 PM

hi all, i need ur help again.

i would to read xml file, here's the structure:
<?xml version="1.0" encoding="utf-8"?>
<a>
  <b>
	<DependentVariable>......</DependentVariable>
	<IndependentVariable>
	  <VariableName>....</VariableName>
	  <VariableCategory>....</VariableCategory>
	  <VariableName>...</VariableName>
	  <VariableCategory>....</VariableCategory>
	  <VariableName>....</VariableName>
.  
	</IndependentVariable>
	<N>
	  <c>7</c>
	  <d>12</d>
	  <e>1</e>
	</NSpecification>
	<BestW>
	  <First>
		<Hidn-0>
		  <Value>0,0147006277837724</Value>
		  <Value>0,0157365235714387</Value>
		  <Value>-1,11479182675768</Value>
		  <Value>0,0147780518775682</Value>
		  <Value>0,0148113036169957</Value>
		  <Value>0,315371593901279</Value>
		  <Value>0,0030341922792291</Value>
		</Hidn-0>
		<Hidn-1>
		  <Value>0,0146706468020328</Value>
		  <Value>0,0157060404133481</Value>
		  <Value>-1,11414990250194</Value>
		  <Value>0,0147480141743419</Value>
		  <Value>0,0147812516098906</Value>
		  <Value>0,315157884993974</Value>
		  <Value>0,00298436066283365</Value>
		</Hidn-1>
		<Hidn-2>
		  <Value>-0,00165436430868364</Value>
		  <Value>-0,0019115230322191</Value>
		  <Value>0,278033519530958</Value>
		  <Value>-0,00167089935202396</Value>
		  <Value>-0,00167946935543082</Value>
		  <Value>-0,0703327175636354</Value>
		  <Value>0,00539260108762332</Value>
		</Hidn-2>
		<Hidn-3>
		  <Value>-0,0200518603482264</Value>
		  <Value>-0,0211596601398058</Value>
		  <Value>1,21263236092843</Value>
		  <Value>-0,0201380522230107</Value>
		  <Value>-0,0201733038325222</Value>
		  <Value>-0,348147930579168</Value>
		  <Value>-0,0119500812283</Value>
		</Hidn-3>
		<Hidn-4>
		  <Value>-0,0356394007206027</Value>
		  <Value>-0,0368627296222549</Value>
		  <Value>1,4050221728927</Value>
		  <Value>-0,0357432786281674</Value>
		  <Value>-0,0357815068104257</Value>
		  <Value>-0,41337471390208</Value>
		  <Value>-0,0368384665743891</Value>
		</Hidn-4>
		<Hidn-5>
		  <Value>0,0114434130154911</Value>
		  <Value>0,0124143948364974</Value>
		  <Value>-1,03537309801384</Value>
		  <Value>0,0115139190375344</Value>
		  <Value>0,0115452887337431</Value>
		  <Value>0,289115950006206</Value>
		  <Value>-0,00229970652017647</Value>
		</Hidn-5>
		<Hidn-6>
		  <Value>-0,00432838710184953</Value>
		  <Value>-0,00496052963614536</Value>
		  <Value>0,672318730000199</Value>
		  <Value>-0,00437051861806568</Value>
		  <Value>-0,00439136957066341</Value>
		  <Value>-0,176908603761612</Value>
		  <Value>0,010305278620259</Value>
		</Hidn-6>
		<Hidn-7>
		  <Value>0,192694258364078</Value>
		  <Value>0,194302333052841</Value>
		  <Value>-2,51205573251831</Value>
		  <Value>0,192890602900543</Value>
		  <Value>0,192936940732418</Value>
		  <Value>0,762368107228318</Value>
		  <Value>0,245087879790184</Value>
		</Hidn-7>
		<Hidn-8>
		  <Value>0,000633579432990509</Value>
		  <Value>0,000730452951856147</Value>
		  <Value>-0,10512765110207</Value>
		  <Value>0,000639775327347678</Value>
		  <Value>0,000643009188226854</Value>
		  <Value>0,0264127251131245</Value>
		  <Value>-0,00208781591796582</Value>
		</Hidn-8>
		<Hidn-9>
		  <Value>-0,194985207746534</Value>
		  <Value>-0,196598493656734</Value>
		  <Value>2,53094313669977</Value>
		  <Value>-0,195182791684114</Value>
		  <Value>-0,195229229430789</Value>
		  <Value>-0,7670979889635</Value>
		  <Value>-0,248048667033084</Value>
		</Hidn-9>
		<Hidn-10>
		  <Value>-0,00526833801529252</Value>
		  <Value>-0,00598276174223044</Value>
		  <Value>0,757549932103763</Value>
		  <Value>-0,00531663070252195</Value>
		  <Value>-0,00534010915689824</Value>
		  <Value>-0,201882485606762</Value>
		  <Value>0,0101598695845531</Value>
		</Hidn-10>
	  </First>
	  <Last>
		<Value>-0,266322541399632</Value>
		<Value>-0,266211352603531</Value>
		<Value>0,0767660819648505</Value>
		<Value>0,2831632942169</Value>
		<Value>0,319018080821374</Value>
		<Value>-0,252324406673804</Value>
		<Value>0,177346551158611</Value>
		<Value>-0,835283976826648</Value>
		<Value>-0,0292499451014532</Value>
	  </Last>
	</BestW>
  </b>
</a>




i get exception : 'Element' is an invalid XmlNodeType.


i don't understand about xml file yet. :(

thanks before

This post has been edited by izzahaf: 01 July 2009 - 10:45 PM


Is This A Good Question/Topic? 0
  • +

Replies To: get double value with comma in xml file

#2 masteryee  Icon User is offline

  • D.I.C Regular

Reputation: 40
  • View blog
  • Posts: 271
  • Joined: 16-May 09

Re: get double value with comma in xml file

Posted 01 July 2009 - 09:50 PM

If you saved your XML as a .xml file and opened it in Internet Explorer or some other XML viewer, you'll notice right away what's wrong:

.  
    </IndependentVariable>
    <N>
      <c>7</c>
      <d>12</d>
      <e>1</e>
    </NSpecification>



Notice the "N" open tag does not match the "NSpecification" closing tag. Rename one of them to match the other. You can also remove that extra dot above the "IndependentVariable" closing tag.

I don't know if this will fix your problem, but it's a start.
Was This Post Helpful? 0
  • +
  • -

#3 izzahaf  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 112
  • Joined: 12-March 09

Re: get double value with comma in xml file

Posted 01 July 2009 - 10:40 PM

View Postmasteryee, on 1 Jul, 2009 - 08:50 PM, said:

If you saved your XML as a .xml file and opened it in Internet Explorer or some other XML viewer, you'll notice right away what's wrong:

.  
    </IndependentVariable>
    <N>
      <c>7</c>
      <d>12</d>
      <e>1</e>
    </NSpecification>



Notice the "N" open tag does not match the "NSpecification" closing tag. Rename one of them to match the other. You can also remove that extra dot above the "IndependentVariable" closing tag.

I don't know if this will fix your problem, but it's a start.


thx masteryee.

but i have problem again, in xml file, double value written as comma(,) to separated decimal, but when read it use readcontentelementasDouble() it can't be read, bacause double value is in dot(.). what should i do?
Was This Post Helpful? 0
  • +
  • -

#4 masteryee  Icon User is offline

  • D.I.C Regular

Reputation: 40
  • View blog
  • Posts: 271
  • Joined: 16-May 09

Re: get double value with comma in xml file

Posted 02 July 2009 - 08:10 AM

The only way I know how to treat the commas as a decimal point is:

using System.Globalization;
...
NumberFormatInfo numberFormat = new NumberFormatInfo();
numberFormat.NumberDecimalSeparator = ",";
double value = Convert.ToDouble("9,123", numberFormat); // or Double.Parse()


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1