MSXML XPATH & String with Single Quote & Double Quote - visual-c++

I am using Escaping Strings in XPath.
My String in XML File is :
"Test ' both " quotes"::LGC"
So I converted it into XPath strings :
Value[#Name=\"concat(\"Test ' both \",'\" quotes\"::LGC')\"]
But still MSXML Select Single Node return me E-FAIL.
Any idea what I am missing XPath strings ?

Related

XPath concat function: \n appears as text

I 'm wring Xpath scripts using concat function to display the result in lines using XPath 1.0
XML example
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XPath
concat("To : ", /note/to , ' \n ', "From : ", /note/from, ' \n ', "Heading : ", /note/heading, ' \n ', "Body : ", /note/body)
Result
To : Tove \n From : Jani \n Heading : Reminder \n Body : Don't forget me this weekend!
However when I use the concat with two element and "\n" in between it works fine.
xPath:
concat("To : ", /note/to , ' \n ', "From : ", /note/from)
Result:
To : Tove
From : Jani
XPath doesn't recognise backslash as an escape character. "\n" simply represents the two characters "backslash, 'n'", it doesn't represent a newline.
If your XPath expression is embedded in a host language such as Java or C#, then the host language will convert \n to newline before the XPath engine ever sees it. But you don't say anything about the host language in which the expressions appear.
If your XPath expression appears within XSLT or XQuery, then you should write a newline as
or . If it's some other environment, then you can use a literal newline.
So the answer is, it all depends on the host environment in which you are writing these expressions.

Nested strings for text(,format) conversion

How do you use Text() with a format that has a string inside it ?
=TEXT(A1,"Comfi+"#0"(JO)";"Comfi-"#0"(JO)")
Tried """ both the inner string :
=TEXT(A1," """Comfi+"""#0"""(JO)""";"""Comfi-"""#0"(JO)""" ")
Same result with &char(34)&
Similar issue here, but I couldn't transpose the solution to my problem : How to create strings containing double quotes in Excel formulas?
Post Solution edit :
Building an almanac/calendar with the following (now fixed)formula :
=CONCATENATE(
TEXT(Format!K25,"d"),
" J+",
Format!S25,
" ",
TEXT(Format!AA25,"""Comfi+""#0""(JO)"";""Comfi-""#0""(JO)"""),
" ",
Format!AI25
)
Giving the following output in each cell :
9
J+70
Comfi+21(JO)
CRG
You've got too many quotation marks inside:
=TEXT(A1,"""Comfi+""#0""(JO)"";""Comfi-""#0""(JO)""")
You were tripling many of the inside quotation marks.
Personally, doubling up double-quotes within a quoted string is something I try to avoid at all costs. You can 'escape' the text into literals with a backslash.
=TEXT(A1,"\C\o\m\f\i+#0\(\J\O\);\C\o\m\f\i-#0\(\J\O\)")
'alternately
="Comfi"&text(a1, "+#0;-#0")&"(JO)"
Not all of those actually need to be escaped; only reserved characters. However, I usually escape them all and let Excel sort them out.

Escaping quotes and delimiters in CSV files with Excel

I try to import a CSV file in Excel, using ; as delimiters, but some columns contains
; and/or quotes.
My problem is : I can use double quotes to ignore the delimiters for a specific string, but if there is a double quote inside the string, it ignores delimiters until the first double quote, but not after.
I don't know if it's clear, it's not that easy to explain.
I will try to explain with a example :
Suppose I have this string this is a;test : I use double quotes around the string, to ignore the delimiter => It works.
Now if this string contains delimiters AND double quotes : my trick doesn't work anymore. For example if I have the string this; is" a;test : My added double quotes around the string ignore delimiters for the first part (the delimiter in the part this; is is correctly ignored, but since there is a double quote after, Excel doesn't ignore the next delimiter in the a;test part.
I tried my best to be as clear as possible, I hope you'll understand what is the problem.
When reading in a quoted string in a csv file, Excel will interpret all pairs of double-quotes ("") with single double-quotes(").
so "this; is"" a;test" will be converted to one cell containing this; is" a;test
So replace all double-quotes in your strings with pairs of double quotes.
Excel will reverse this process when exporting as CSV.
Here is some CSV
a,b,c,d,e
"""test1""",""",te"st2,"test,3",test"4,test5
And this is how it looks after importing into Excel:
Import your Excel file in openOffice and export as CSV (column escaped with " unlike Excel csv, utf8, comma against ";").

Apex- no viable alternative at character ' ' while substring

I am trying to get substring fom a string. I have a xml response and I want to get only few tags and there values to parse.
but I am getting error :- no viable alternative at character ' '
responseObj.xmlResponse = response.getBody();
String xmlbody =response.getBody();
order OrderID=new order();
String substr=xmlbody.substring(xmlbody.indexOf("<OrderID>"));
Try this.
String substr=xmlbody.substring(xmlbody.indexOf('<OrderID>'));

VB6 Split String with < > Characters

I am trying to split something like this
When the Source is from a webpage and contains this value multiple times, but I don't think will split it because of the "<" character, any way around this?
SourceSplit = Split(Source, "<span class='BText' id='BText'>")
I tried using Chr(60) instead, didn't like that either, any ideas?
Thanks for any help
I would guess that the HTML uses double quotes for attribute values, not single. You need to escape the double quotes:
SourceSplit = Split(Source, "<span class=""BText"" id=""BText"">")

Resources