1

Topic: Sampling from XML a file with cyrillic

How truly to make sampling of branches from XML a file with Russian letters in the name of branches?
I try a following code there is an error with the incorrect character in line "".

Set xmlParser = CreateObject ("Msxml2.DOMDocument.6.0")
xmlParser.async = False
xmlParser.load SourceFolder AND "\" AND objFile. Name
' It is deduced XML document contents
WScript. Echo xmlParser.xml
Set colNodes = xmlParser.getElementsByTagName ("")
Set xmlParser = Nothing

XML

<? xml version = "1.0" encoding = "UTF-8"?>
<A file of VersForm = "3.00">
<ZAPNOOSTAT VidZapr = "4" DataPoSost = "2017-06-25" DataZapr = "2017-08-01" KodOsnov = "1011" TipZapr = "4" NomZapr = "23\77-">
<SvNO KodNO = "1655"/>
<SvBank NomFil = "0"/>
<>
<PlJuL of a check point = "165001001"/>
</svpl>
<> 1 </povsem>
</zapnoostat>
</a file>

2

Re: Sampling from XML a file with cyrillic

udg wrote:

I Try a following code there is an error with the incorrect character in line "".

all works for me. However, returns 0 nodes, but errors are not present any

3

Re: Sampling from XML a file with cyrillic

And the coding precisely UTF-8? Not win-1251? (And not KOI8R, not by the night be remembered)? At MSXML very bad friendship with . Characters in  codings.

4

Re: Sampling from XML a file with cyrillic

Very Pavlovny wrote:

And the coding precisely UTF-8?

There was a same idea. Checked up. The code all the same does not return errors

5

Re: Sampling from XML a file with cyrillic

Very Pavlovny wrote:

At MSXML very bad friendship with . Characters in  codings.

the First time I hear. If in a prologue the coding is specified correctly any problems did not meet

6

Re: Sampling from XML a file with cyrillic

Found the reason it appears the code with Russian characters in VBS broke at execution.
After change of coding VBS was UTF-8, changed on ANSI and all began to work.

7

Re: Sampling from XML a file with cyrillic

[quote = _ Vasilisk _] the First time I hear. If in a prologue the coding is specified correctly any problems did not meet

Probably, in when I came across problems with  codings, in a prologue the coding has not been specified absolutely. If it is specified - yes, everything is all right, at least, in MSXML 6.0.
However in this case, if the coding of a file of wines-1251 (and in a prologue it is specified UTF-8)  does not boot - see , at start , causing a loading script xml, is produced

 Can't load D:\Trash\1\1.xml: In the text comment the inadmissible sign is found out.
D:\Trash\1\2.xml loaded 

Files 1.xml and 2.xml from  differ only the coding - the first in win-1251, the second in UTF-8. Contents - as in start posting.
Loading script:

var xmlFile = new ActiveXObject ("Scripting. FileSystemObject").BuildPath (
new ActiveXObject ("WScript. Shell").CurrentDirectory, WScript.arguments (0)
);
var dom = new ActiveXObject ("MSXML2.DOMDocument.6.0");
dom.async = false;
dom.validateOnParse = false;
dom.load (xmlFile);
if (dom.parseError.errorCode! =0)
{
WScript. Echo ("Can't load" +xmlFile + ":" + dom.parseError.reason);
WScript. Quit (-1);
}
WScript. Echo (xmlFile + "loaded");