Home > Back-end >  How to check the syntax of XML BCB?
How to check the syntax of XML BCB?

Time:10-24

I grab by BCB information web page, the user name column can appear sometimes & lt;> This time, will cause the XML syntax is not correct, program cannot proceed, excuse me what method can solve this problem?
 & lt; ? The XML version='1.0' encoding='GBK'?> 

KSUSER1 & lt; NJ>
1270 & lt;/TEMP>
30 & lt;/HUMI>



When reading the USER, due to the USER in because there are & lt; NJ> , because its not with the matching & lt;/> , so read XML will make a mistake, is there any way I can solve this problem?

CodePudding user response:

Replace him as a string of ABC, parsing out replacement back

CodePudding user response:

The key word is not fixed, sometimes it is & lt; NJ> Sometimes it may be & lt; Any other content & gt;

CodePudding user response:

 STR=StringReplace (STR, "& lt; NJ>" , "ABC", TReplaceFlags () & lt; 

CodePudding user response:

reference ksrsoft reply: 3/f
C/C + + code? 1 STR=StringReplace (STR, "& lt; NJ>" , "ABC", TReplaceFlags () & lt;

If only fixed words I know, but the user is not fixed, sometimes it is an ID number, sometimes referred to as ", so it is not sure, replace the affirmation is not directly,

CodePudding user response:

That with StringList as text reading,
STR=the list [2]. The Trim ();
STR. Delete (1)//remove the first & lt;
STR. Pos (& lt; "" ); To get the second & lt; The location of the
And then the interception,
The list [2]=STR;
To save into XML file parsing line no

CodePudding user response:

Replace or delete individual can be directly, but stability is a bit poor, if the name is included in multiple & lt;> How to do?
For example,
KSUSER1 & lt;

CodePudding user response:

Storage time can directly replace the
This kind of special character, it is best carried out in accordance with the few characters below replacement, (why say so? See the above two problems)
& lt; & gt;> Greater than
& amp; & And
& Apos; 'single quotes
& quot; "Double quotation marks

CodePudding user response:

Data is others, not their own data, so there is no way to control, now the only way out of the clay, pos + the substring to locate the intercept after replaced the,
If can judge the XML syntax to no right, just I will skip this record,
  • Related