C# School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C# Expert!

Join 300,400 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,587 people online right now. Registration is fast and FREE... Join Now!




get double value with comma in xml file

 

get double value with comma in xml file

izzahaf

1 Jul, 2009 - 07:31 PM
Post #1

D.I.C Head
**

Joined: 12 Mar, 2009
Posts: 98

hi all, i need ur help again.

i would to read xml file, here's the structure:
CODE

<?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. sad.gif

thanks before

This post has been edited by izzahaf: 1 Jul, 2009 - 09:45 PM

User is offlineProfile CardPM
+Quote Post


masteryee

RE: Get Double Value With Comma In Xml File

1 Jul, 2009 - 08:50 PM
Post #2

D.I.C Regular
***

Joined: 16 May, 2009
Posts: 266



Thanked: 36 times
My Contributions
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:

xml

.
</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.
User is offlineProfile CardPM
+Quote Post

izzahaf

RE: Get Double Value With Comma In Xml File

1 Jul, 2009 - 09:40 PM
Post #3

D.I.C Head
**

Joined: 12 Mar, 2009
Posts: 98

QUOTE(masteryee @ 1 Jul, 2009 - 08: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:

xml

.
</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?


User is offlineProfile CardPM
+Quote Post

masteryee

RE: Get Double Value With Comma In Xml File

2 Jul, 2009 - 07:10 AM
Post #4

D.I.C Regular
***

Joined: 16 May, 2009
Posts: 266



Thanked: 36 times
My Contributions
The only way I know how to treat the commas as a decimal point is:

csharp

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

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 10:17PM

Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month