Analysis on Format strings and XML files (rough)

xiaoxiao2021-03-06  14

2, try, the Format parameter in the toString () method (which is string), format = "n", indicates that the current value is output according to the value of the value. Format = "c" is a currency format. In the method of format conversion, there is an iFormatProvider interface, which can be implemented by CultureInfo, with a property in CultureInfo to NumberFormatinfo, which can be used to format the value of the value.

CultureInfo Ci = New CultureInfo ("EN-US");

INT VAL = -1234;

String Retval = Val.Tostring ("N", CI);

// Output console.writeLine (RetVal);

Ci.Numberformat.NumbergroupseParetor = "";

Ci.Numberformat.NumberDecimaldigits = 1;

// Output console.writeLine (RetVal);

------------------------------ The result of the output is: -1, 234.00-1234, 0

2004.7.10

1. Loading XML data using XMLTextReader than XMLDocument is faster and more performance. Although XMLTextReader and XMLDocument can get data in XML, but I still choose to use, XpathDocument and XPathnavigator two classes.

XpathDocument Doc = New XpathDocument (XMLFilePath);

Xpathnavigator NAV = doc.createnavigator ();

/ / Specify the position of the node xpathnodeiterator it = nav.select ("/ product / name");

// Move to the next node, the next node is a text node. ITE.MOVENEXT ();

// Print out the text in the text node under / produter / name. Console.writeLine (ITE.Current.Value);

/ / Specify the position of the node ITE = nav.select ("/ product / support / name");

// Move to the next node, the next node is a text node. ITE.MOVENEXT ();

// Print out the text in the text node under / product / support / name. Console.writeLine (ITE.Current.Value);

转载请注明原文地址:https://www.9cbs.com/read-49577.html

New Post(0)