Discussion:
Difference
(too old to reply)
James P
2004-11-06 20:30:56 UTC
Permalink
When I call http://www.webservicex.net/RealTimeMarketData.asmx the output
xml does not contain < etc.
When I call http://www.webservicex.net/stockquote.asmx the output xml has
these characters.

When I open it in IE, everything looks ok.

Any idea why and how I can get the output without those characters?

Thanks.
James
http://www.poovathummoottil.com
Paul Baker [MVP, Windows - SDK]
2004-11-08 14:19:17 UTC
Permalink
James,

Please give specific examples. I tried both and I saw nothing odd.

Paul
Post by James P
When I call http://www.webservicex.net/RealTimeMarketData.asmx the output
xml does not contain < etc.
When I call http://www.webservicex.net/stockquote.asmx the output xml has
these characters.
When I open it in IE, everything looks ok.
Any idea why and how I can get the output without those characters?
Thanks.
James
http://www.poovathummoottil.com
James P
2004-11-09 04:14:55 UTC
Permalink
This is the sample code:
#include <windows.h>
#include <wininet.h>
#include <stdio.h>

void main()
{
FILE *fp = fopen("c:\\test.txt", "a");
if (!fp)
return;
BOOL InetCanConnect = FALSE;
HINTERNET hiOpen = NULL;
HINTERNET hiFile = NULL;
TCHAR webData[1024];
DWORD dwRead;
if (ERROR_SUCCESS != InternetAttemptConnect(0))
goto end;
if (NULL == (hiOpen = InternetOpen("TestApp", INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, 0x0)))
goto end;
if (NULL != (hiFile = InternetOpenUrl(hiOpen,
"http://www.webservicex.net/RealTimeMarketData.asmx/Quote?Symbol=MSFT",
NULL, 0, 0, 0)))
{
InternetReadFile(hiFile, webData, 1023, &dwRead);
InternetCloseHandle(hiFile);
webData[dwRead] = 0;
fprintf(fp, "%s\n", webData);
}
if (NULL != (hiFile = InternetOpenUrl(hiOpen,
"http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=MSFT",
NULL, 0, 0, 0)))
{
InternetReadFile(hiFile, webData, 1023, &dwRead);
InternetCloseHandle(hiFile);
webData[dwRead] = 0;
fprintf(fp, "%s\n", webData);
}
InternetCloseHandle(hiOpen);
end:
fclose(fp);
}

The file content is:
<?xml version="1.0" encoding="utf-8"?>

<QuoteList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.webservicex.net/">

<QuoteLists>

<Quote>

<Symbol>MSFT</Symbol>

<DateTime>19:59:57.416-05:00</DateTime>

<MatchedShares>17563379</MatchedShares>

<Price>29.34</Price>

</Quote>

</QuoteLists>

</QuoteList>
<?xml version="1.0" encoding="utf-8"?>

<string
xmlns="http://www.webserviceX.NET/">&lt;StockQuotes&gt;&lt;Stock&gt;&lt;Symbol&gt;MSFT&lt;/Symbol&gt;&lt;Last&gt;29.28&lt;/Last&gt;&lt;Date&gt;11/8/2004&lt;/Date&gt;&lt;Time&gt;4:00pm&lt;/Time&gt;&lt;Change&gt;-0.03&lt;/Change&gt;&lt;Open&gt;29.18&lt;/Open&gt;&lt;High&gt;29.48&lt;/High&gt;&lt;Low&gt;29.13&lt;/Low&gt;&lt;Volume&gt;116089016&lt;/Volume&gt;&lt;MktCap&gt;318.1B&lt;/MktCap&gt;&lt;PreviousClose&gt;29.31&lt;/PreviousClose&gt;&lt;PercentageChange&gt;-0.10%&lt;/PercentageChange&gt;&lt;AnnRange&gt;24.01
-
29.89&lt;/AnnRange&gt;&lt;Earns&gt;0.78&lt;/Earns&gt;&lt;P-E&gt;37.58&lt;/P-E&gt;&lt;Name&gt;MICROSOFT
CP&lt;/Name&gt;&lt;/Stock&gt;&lt;/StockQuotes&gt;</string>

James
Post by Paul Baker [MVP, Windows - SDK]
James,
Please give specific examples. I tried both and I saw nothing odd.
Paul
Post by James P
When I call http://www.webservicex.net/RealTimeMarketData.asmx the output
xml does not contain &lt; etc.
When I call http://www.webservicex.net/stockquote.asmx the output xml has
these characters.
When I open it in IE, everything looks ok.
Any idea why and how I can get the output without those characters?
Thanks.
James
http://www.poovathummoottil.com
Paul Baker [MVP, Windows - SDK]
2004-11-09 21:17:29 UTC
Permalink
Oh, now I get it. You don't need any source code to prove a point, because
it's nothing you're doing. Let me explain.

You are using this URL:
http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=MSFT

The response has a lot of instances of "&lt;" in it.

But in Internet Explorer it looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<string
xmlns="http://www.webserviceX.NET/"><StockQuotes><Stock><Symbol>MSFT</Symbol
<Last>29.77</Last><Date>11/9/2004</Date><Time>3:59pm</Time><Change>+0.49</C
hange><Open>29.43</Open><High>29.89</High><Low>29.35</Low><Volume>96263152</
Volume><MktCap>323.5B</MktCap><PreviousClose>29.28</PreviousClose><Percentag
eChange>+1.67%</PercentageChange><AnnRange>24.01 -
29.89</AnnRange><Earns>0.78</Earns><P-E>37.54</P-E><Name>MICROSOFT
CP</Name></Stock></StockQuotes></string>

That's because Internet Explorer is parsing the XML and decoding the &lt; to
<.

You too need to parse the XML, for which you will need an XML parser. MSXML
is a free one available from Microsoft and included in recent versions of
Internet Explorer and Windows.

Paul
#include <windows.h>
#include <wininet.h>
#include <stdio.h>
void main()
{
FILE *fp = fopen("c:\\test.txt", "a");
if (!fp)
return;
BOOL InetCanConnect = FALSE;
HINTERNET hiOpen = NULL;
HINTERNET hiFile = NULL;
TCHAR webData[1024];
DWORD dwRead;
if (ERROR_SUCCESS != InternetAttemptConnect(0))
goto end;
if (NULL == (hiOpen = InternetOpen("TestApp",
INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, 0x0)))
goto end;
if (NULL != (hiFile = InternetOpenUrl(hiOpen,
"http://www.webservicex.net/RealTimeMarketData.asmx/Quote?Symbol=MSFT",
NULL, 0, 0, 0)))
{
InternetReadFile(hiFile, webData, 1023, &dwRead);
InternetCloseHandle(hiFile);
webData[dwRead] = 0;
fprintf(fp, "%s\n", webData);
}
if (NULL != (hiFile = InternetOpenUrl(hiOpen,
"http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=MSFT",
NULL, 0, 0, 0)))
{
InternetReadFile(hiFile, webData, 1023, &dwRead);
InternetCloseHandle(hiFile);
webData[dwRead] = 0;
fprintf(fp, "%s\n", webData);
}
InternetCloseHandle(hiOpen);
fclose(fp);
}
<?xml version="1.0" encoding="utf-8"?>
<QuoteList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.webservicex.net/">
<QuoteLists>
<Quote>
<Symbol>MSFT</Symbol>
<DateTime>19:59:57.416-05:00</DateTime>
<MatchedShares>17563379</MatchedShares>
<Price>29.34</Price>
</Quote>
</QuoteLists>
</QuoteList>
<?xml version="1.0" encoding="utf-8"?>
<string
-
29.89&lt;/AnnRange&gt;&lt;Earns&gt;0.78&lt;/Earns&gt;&lt;P-E&gt;37.58&lt;/P-
E&gt;&lt;Name&gt;MICROSOFT
James
Post by Paul Baker [MVP, Windows - SDK]
James,
Please give specific examples. I tried both and I saw nothing odd.
Paul
Post by James P
When I call http://www.webservicex.net/RealTimeMarketData.asmx the output
xml does not contain &lt; etc.
When I call http://www.webservicex.net/stockquote.asmx the output xml has
these characters.
When I open it in IE, everything looks ok.
Any idea why and how I can get the output without those characters?
Thanks.
James
http://www.poovathummoottil.com
James
2004-11-09 21:38:35 UTC
Permalink
Thanks Paul.

But my question is one URL produces output with lots of &lt; etc but the
other one does not. That is why I sent the complete code.

Also, the output says the encoding is utf-8 whereas the XMLDOM supports only
utf-16.

Thanks.
James
Post by Paul Baker [MVP, Windows - SDK]
Oh, now I get it. You don't need any source code to prove a point, because
it's nothing you're doing. Let me explain.
http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=MSFT
The response has a lot of instances of "&lt;" in it.
<?xml version="1.0" encoding="utf-8" ?>
<string
xmlns="http://www.webserviceX.NET/"><StockQuotes><Stock><Symbol>MSFT</Symbol
Post by Paul Baker [MVP, Windows - SDK]
<Last>29.77</Last><Date>11/9/2004</Date><Time>3:59pm</Time><Change>+0.49</C
hange><Open>29.43</Open><High>29.89</High><Low>29.35</Low><Volume>96263152</
Volume><MktCap>323.5B</MktCap><PreviousClose>29.28</PreviousClose><Percentag
Post by Paul Baker [MVP, Windows - SDK]
eChange>+1.67%</PercentageChange><AnnRange>24.01 -
29.89</AnnRange><Earns>0.78</Earns><P-E>37.54</P-E><Name>MICROSOFT
CP</Name></Stock></StockQuotes></string>
That's because Internet Explorer is parsing the XML and decoding the &lt; to
<.
You too need to parse the XML, for which you will need an XML parser. MSXML
is a free one available from Microsoft and included in recent versions of
Internet Explorer and Windows.
Paul
Post by James P
#include <windows.h>
#include <wininet.h>
#include <stdio.h>
void main()
{
FILE *fp = fopen("c:\\test.txt", "a");
if (!fp)
return;
BOOL InetCanConnect = FALSE;
HINTERNET hiOpen = NULL;
HINTERNET hiFile = NULL;
TCHAR webData[1024];
DWORD dwRead;
if (ERROR_SUCCESS != InternetAttemptConnect(0))
goto end;
if (NULL == (hiOpen = InternetOpen("TestApp",
INTERNET_OPEN_TYPE_PRECONFIG,
Post by James P
NULL, NULL, 0x0)))
goto end;
if (NULL != (hiFile = InternetOpenUrl(hiOpen,
"http://www.webservicex.net/RealTimeMarketData.asmx/Quote?Symbol=MSFT",
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
NULL, 0, 0, 0)))
{
InternetReadFile(hiFile, webData, 1023, &dwRead);
InternetCloseHandle(hiFile);
webData[dwRead] = 0;
fprintf(fp, "%s\n", webData);
}
if (NULL != (hiFile = InternetOpenUrl(hiOpen,
"http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=MSFT",
NULL, 0, 0, 0)))
{
InternetReadFile(hiFile, webData, 1023, &dwRead);
InternetCloseHandle(hiFile);
webData[dwRead] = 0;
fprintf(fp, "%s\n", webData);
}
InternetCloseHandle(hiOpen);
fclose(fp);
}
<?xml version="1.0" encoding="utf-8"?>
<QuoteList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.webservicex.net/">
<QuoteLists>
<Quote>
<Symbol>MSFT</Symbol>
<DateTime>19:59:57.416-05:00</DateTime>
<MatchedShares>17563379</MatchedShares>
<Price>29.34</Price>
</Quote>
</QuoteLists>
</QuoteList>
<?xml version="1.0" encoding="utf-8"?>
<string
-
E&gt;&lt;Name&gt;MICROSOFT
Post by James P
James
Post by Paul Baker [MVP, Windows - SDK]
James,
Please give specific examples. I tried both and I saw nothing odd.
Paul
Post by James P
When I call http://www.webservicex.net/RealTimeMarketData.asmx the
output
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
xml does not contain &lt; etc.
When I call http://www.webservicex.net/stockquote.asmx the output xml
has
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
these characters.
When I open it in IE, everything looks ok.
Any idea why and how I can get the output without those characters?
Thanks.
James
http://www.poovathummoottil.com
Paul Baker [MVP, Windows - SDK]
2004-11-09 22:28:41 UTC
Permalink
James,

It is simple how they implemented their web services. These are two
different web services.

If one of them is wrong, you would have to contact them and explain why. In
the second web service, the "<" and ">" are actually part of the data, not
part of the XML syntax which, I agree, seems a bit odd.

Maybe the person who wrote the first one knows what they're doing and the
person who wrote the second one does not? I just don't know.

Paul
Post by James
Thanks Paul.
But my question is one URL produces output with lots of &lt; etc but the
other one does not. That is why I sent the complete code.
Also, the output says the encoding is utf-8 whereas the XMLDOM supports only
utf-16.
Thanks.
James
Post by Paul Baker [MVP, Windows - SDK]
Oh, now I get it. You don't need any source code to prove a point, because
it's nothing you're doing. Let me explain.
http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=MSFT
The response has a lot of instances of "&lt;" in it.
<?xml version="1.0" encoding="utf-8" ?>
<string
xmlns="http://www.webserviceX.NET/"><StockQuotes><Stock><Symbol>MSFT</Symbol
Post by James
<Last>29.77</Last><Date>11/9/2004</Date><Time>3:59pm</Time><Change>+0.49</C
hange><Open>29.43</Open><High>29.89</High><Low>29.35</Low><Volume>96263152</
Volume><MktCap>323.5B</MktCap><PreviousClose>29.28</PreviousClose><Percentag
Post by James
Post by Paul Baker [MVP, Windows - SDK]
eChange>+1.67%</PercentageChange><AnnRange>24.01 -
29.89</AnnRange><Earns>0.78</Earns><P-E>37.54</P-E><Name>MICROSOFT
CP</Name></Stock></StockQuotes></string>
That's because Internet Explorer is parsing the XML and decoding the
&lt;
Post by James
to
Post by Paul Baker [MVP, Windows - SDK]
<.
You too need to parse the XML, for which you will need an XML parser.
MSXML
Post by Paul Baker [MVP, Windows - SDK]
is a free one available from Microsoft and included in recent versions of
Internet Explorer and Windows.
Paul
Post by James P
#include <windows.h>
#include <wininet.h>
#include <stdio.h>
void main()
{
FILE *fp = fopen("c:\\test.txt", "a");
if (!fp)
return;
BOOL InetCanConnect = FALSE;
HINTERNET hiOpen = NULL;
HINTERNET hiFile = NULL;
TCHAR webData[1024];
DWORD dwRead;
if (ERROR_SUCCESS != InternetAttemptConnect(0))
goto end;
if (NULL == (hiOpen = InternetOpen("TestApp",
INTERNET_OPEN_TYPE_PRECONFIG,
Post by James P
NULL, NULL, 0x0)))
goto end;
if (NULL != (hiFile = InternetOpenUrl(hiOpen,
"http://www.webservicex.net/RealTimeMarketData.asmx/Quote?Symbol=MSFT",
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
NULL, 0, 0, 0)))
{
InternetReadFile(hiFile, webData, 1023, &dwRead);
InternetCloseHandle(hiFile);
webData[dwRead] = 0;
fprintf(fp, "%s\n", webData);
}
if (NULL != (hiFile = InternetOpenUrl(hiOpen,
"http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=MSFT",
NULL, 0, 0, 0)))
{
InternetReadFile(hiFile, webData, 1023, &dwRead);
InternetCloseHandle(hiFile);
webData[dwRead] = 0;
fprintf(fp, "%s\n", webData);
}
InternetCloseHandle(hiOpen);
fclose(fp);
}
<?xml version="1.0" encoding="utf-8"?>
<QuoteList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.webservicex.net/">
<QuoteLists>
<Quote>
<Symbol>MSFT</Symbol>
<DateTime>19:59:57.416-05:00</DateTime>
<MatchedShares>17563379</MatchedShares>
<Price>29.34</Price>
</Quote>
</QuoteLists>
</QuoteList>
<?xml version="1.0" encoding="utf-8"?>
<string
-
E&gt;&lt;Name&gt;MICROSOFT
Post by James P
James
in
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
James,
Please give specific examples. I tried both and I saw nothing odd.
Paul
Post by James P
When I call http://www.webservicex.net/RealTimeMarketData.asmx the
output
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
xml does not contain &lt; etc.
When I call http://www.webservicex.net/stockquote.asmx the output xml
has
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
these characters.
When I open it in IE, everything looks ok.
Any idea why and how I can get the output without those characters?
Thanks.
James
http://www.poovathummoottil.com
Paul Baker [MVP, Windows - SDK]
2004-11-10 21:26:09 UTC
Permalink
I might add that this is not, and never was, a WinInet problem. If you wish
to take it further, you should probably post to microsoft.public.xml.soap.

Paul
Post by Paul Baker [MVP, Windows - SDK]
James,
It is simple how they implemented their web services. These are two
different web services.
If one of them is wrong, you would have to contact them and explain why. In
the second web service, the "<" and ">" are actually part of the data, not
part of the XML syntax which, I agree, seems a bit odd.
Maybe the person who wrote the first one knows what they're doing and the
person who wrote the second one does not? I just don't know.
Paul
Post by James
Thanks Paul.
But my question is one URL produces output with lots of &lt; etc but the
other one does not. That is why I sent the complete code.
Also, the output says the encoding is utf-8 whereas the XMLDOM supports
only
Post by James
utf-16.
Thanks.
James
Post by Paul Baker [MVP, Windows - SDK]
Oh, now I get it. You don't need any source code to prove a point,
because
Post by James
Post by Paul Baker [MVP, Windows - SDK]
it's nothing you're doing. Let me explain.
http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=MSFT
The response has a lot of instances of "&lt;" in it.
<?xml version="1.0" encoding="utf-8" ?>
<string
xmlns="http://www.webserviceX.NET/"><StockQuotes><Stock><Symbol>MSFT</Symbol
Post by Paul Baker [MVP, Windows - SDK]
<Last>29.77</Last><Date>11/9/2004</Date><Time>3:59pm</Time><Change>+0.49</C
hange><Open>29.43</Open><High>29.89</High><Low>29.35</Low><Volume>96263152</
Volume><MktCap>323.5B</MktCap><PreviousClose>29.28</PreviousClose><Percentag
Post by Paul Baker [MVP, Windows - SDK]
Post by James
Post by Paul Baker [MVP, Windows - SDK]
eChange>+1.67%</PercentageChange><AnnRange>24.01 -
29.89</AnnRange><Earns>0.78</Earns><P-E>37.54</P-E><Name>MICROSOFT
CP</Name></Stock></StockQuotes></string>
That's because Internet Explorer is parsing the XML and decoding the
&lt;
Post by James
to
Post by Paul Baker [MVP, Windows - SDK]
<.
You too need to parse the XML, for which you will need an XML parser.
MSXML
Post by Paul Baker [MVP, Windows - SDK]
is a free one available from Microsoft and included in recent versions
of
Post by James
Post by Paul Baker [MVP, Windows - SDK]
Internet Explorer and Windows.
Paul
Post by James P
#include <windows.h>
#include <wininet.h>
#include <stdio.h>
void main()
{
FILE *fp = fopen("c:\\test.txt", "a");
if (!fp)
return;
BOOL InetCanConnect = FALSE;
HINTERNET hiOpen = NULL;
HINTERNET hiFile = NULL;
TCHAR webData[1024];
DWORD dwRead;
if (ERROR_SUCCESS != InternetAttemptConnect(0))
goto end;
if (NULL == (hiOpen = InternetOpen("TestApp",
INTERNET_OPEN_TYPE_PRECONFIG,
Post by James P
NULL, NULL, 0x0)))
goto end;
if (NULL != (hiFile = InternetOpenUrl(hiOpen,
"http://www.webservicex.net/RealTimeMarketData.asmx/Quote?Symbol=MSFT",
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
NULL, 0, 0, 0)))
{
InternetReadFile(hiFile, webData, 1023, &dwRead);
InternetCloseHandle(hiFile);
webData[dwRead] = 0;
fprintf(fp, "%s\n", webData);
}
if (NULL != (hiFile = InternetOpenUrl(hiOpen,
"http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=MSFT",
NULL, 0, 0, 0)))
{
InternetReadFile(hiFile, webData, 1023, &dwRead);
InternetCloseHandle(hiFile);
webData[dwRead] = 0;
fprintf(fp, "%s\n", webData);
}
InternetCloseHandle(hiOpen);
fclose(fp);
}
<?xml version="1.0" encoding="utf-8"?>
<QuoteList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.webservicex.net/">
<QuoteLists>
<Quote>
<Symbol>MSFT</Symbol>
<DateTime>19:59:57.416-05:00</DateTime>
<MatchedShares>17563379</MatchedShares>
<Price>29.34</Price>
</Quote>
</QuoteLists>
</QuoteList>
<?xml version="1.0" encoding="utf-8"?>
<string
-
E&gt;&lt;Name&gt;MICROSOFT
Post by James P
James
in
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
James,
Please give specific examples. I tried both and I saw nothing odd.
Paul
Post by James P
When I call http://www.webservicex.net/RealTimeMarketData.asmx the
output
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
xml does not contain &lt; etc.
When I call http://www.webservicex.net/stockquote.asmx the output
xml
Post by James
Post by Paul Baker [MVP, Windows - SDK]
has
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
these characters.
When I open it in IE, everything looks ok.
Any idea why and how I can get the output without those characters?
Thanks.
James
http://www.poovathummoottil.com
James
2004-11-11 18:25:59 UTC
Permalink
I did not realize that the content in the second query was not part of the
xml but rather a string embedded in the xml.

James
http://www.poovathummoottil.com
Post by Paul Baker [MVP, Windows - SDK]
I might add that this is not, and never was, a WinInet problem. If you wish
to take it further, you should probably post to microsoft.public.xml.soap.
Paul
Post by Paul Baker [MVP, Windows - SDK]
James,
It is simple how they implemented their web services. These are two
different web services.
If one of them is wrong, you would have to contact them and explain why.
In
Post by Paul Baker [MVP, Windows - SDK]
the second web service, the "<" and ">" are actually part of the data, not
part of the XML syntax which, I agree, seems a bit odd.
Maybe the person who wrote the first one knows what they're doing and the
person who wrote the second one does not? I just don't know.
Paul
Post by James
Thanks Paul.
But my question is one URL produces output with lots of &lt; etc but the
other one does not. That is why I sent the complete code.
Also, the output says the encoding is utf-8 whereas the XMLDOM supports
only
Post by James
utf-16.
Thanks.
James
in
Post by Paul Baker [MVP, Windows - SDK]
Post by James
Post by Paul Baker [MVP, Windows - SDK]
Oh, now I get it. You don't need any source code to prove a point,
because
Post by James
Post by Paul Baker [MVP, Windows - SDK]
it's nothing you're doing. Let me explain.
http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=MSFT
The response has a lot of instances of "&lt;" in it.
<?xml version="1.0" encoding="utf-8" ?>
<string
xmlns="http://www.webserviceX.NET/"><StockQuotes><Stock><Symbol>MSFT</Symbol
Post by Paul Baker [MVP, Windows - SDK]
<Last>29.77</Last><Date>11/9/2004</Date><Time>3:59pm</Time><Change>+0.49</C
hange><Open>29.43</Open><High>29.89</High><Low>29.35</Low><Volume>96263152</
Volume><MktCap>323.5B</MktCap><PreviousClose>29.28</PreviousClose><Percentag
Post by Paul Baker [MVP, Windows - SDK]
Post by Paul Baker [MVP, Windows - SDK]
Post by James
Post by Paul Baker [MVP, Windows - SDK]
eChange>+1.67%</PercentageChange><AnnRange>24.01 -
29.89</AnnRange><Earns>0.78</Earns><P-E>37.54</P-E><Name>MICROSOFT
CP</Name></Stock></StockQuotes></string>
That's because Internet Explorer is parsing the XML and decoding the
&lt;
Post by James
to
Post by Paul Baker [MVP, Windows - SDK]
<.
You too need to parse the XML, for which you will need an XML parser.
MSXML
Post by Paul Baker [MVP, Windows - SDK]
is a free one available from Microsoft and included in recent versions
of
Post by James
Post by Paul Baker [MVP, Windows - SDK]
Internet Explorer and Windows.
Paul
Post by James P
#include <windows.h>
#include <wininet.h>
#include <stdio.h>
void main()
{
FILE *fp = fopen("c:\\test.txt", "a");
if (!fp)
return;
BOOL InetCanConnect = FALSE;
HINTERNET hiOpen = NULL;
HINTERNET hiFile = NULL;
TCHAR webData[1024];
DWORD dwRead;
if (ERROR_SUCCESS != InternetAttemptConnect(0))
goto end;
if (NULL == (hiOpen = InternetOpen("TestApp",
INTERNET_OPEN_TYPE_PRECONFIG,
Post by James P
NULL, NULL, 0x0)))
goto end;
if (NULL != (hiFile = InternetOpenUrl(hiOpen,
"http://www.webservicex.net/RealTimeMarketData.asmx/Quote?Symbol=MSFT",
Post by Paul Baker [MVP, Windows - SDK]
Post by Paul Baker [MVP, Windows - SDK]
Post by James
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
NULL, 0, 0, 0)))
{
InternetReadFile(hiFile, webData, 1023, &dwRead);
InternetCloseHandle(hiFile);
webData[dwRead] = 0;
fprintf(fp, "%s\n", webData);
}
if (NULL != (hiFile = InternetOpenUrl(hiOpen,
"http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=MSFT",
Post by Paul Baker [MVP, Windows - SDK]
Post by Paul Baker [MVP, Windows - SDK]
Post by James
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
NULL, 0, 0, 0)))
{
InternetReadFile(hiFile, webData, 1023, &dwRead);
InternetCloseHandle(hiFile);
webData[dwRead] = 0;
fprintf(fp, "%s\n", webData);
}
InternetCloseHandle(hiOpen);
fclose(fp);
}
<?xml version="1.0" encoding="utf-8"?>
<QuoteList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.webservicex.net/">
<QuoteLists>
<Quote>
<Symbol>MSFT</Symbol>
<DateTime>19:59:57.416-05:00</DateTime>
<MatchedShares>17563379</MatchedShares>
<Price>29.34</Price>
</Quote>
</QuoteLists>
</QuoteList>
<?xml version="1.0" encoding="utf-8"?>
<string
-
E&gt;&lt;Name&gt;MICROSOFT
Post by James P
James
in
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
James,
Please give specific examples. I tried both and I saw nothing odd.
Paul
Post by James P
When I call http://www.webservicex.net/RealTimeMarketData.asmx
the
Post by Paul Baker [MVP, Windows - SDK]
Post by James
Post by Paul Baker [MVP, Windows - SDK]
output
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
xml does not contain &lt; etc.
When I call http://www.webservicex.net/stockquote.asmx the output
xml
Post by James
Post by Paul Baker [MVP, Windows - SDK]
has
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
these characters.
When I open it in IE, everything looks ok.
Any idea why and how I can get the output without those
characters?
Post by Paul Baker [MVP, Windows - SDK]
Post by James
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
Thanks.
James
http://www.poovathummoottil.com
Paul Baker [MVP, Windows - SDK]
2004-11-11 23:01:04 UTC
Permalink
Yeppers, that's why it gets encoded to &lt;

Paul
Post by James
I did not realize that the content in the second query was not part of the
xml but rather a string embedded in the xml.
James
http://www.poovathummoottil.com
Post by Paul Baker [MVP, Windows - SDK]
I might add that this is not, and never was, a WinInet problem. If you
wish
Post by Paul Baker [MVP, Windows - SDK]
to take it further, you should probably post to
microsoft.public.xml.soap.
Post by James
Post by Paul Baker [MVP, Windows - SDK]
Paul
Post by Paul Baker [MVP, Windows - SDK]
James,
It is simple how they implemented their web services. These are two
different web services.
If one of them is wrong, you would have to contact them and explain why.
In
Post by Paul Baker [MVP, Windows - SDK]
the second web service, the "<" and ">" are actually part of the data,
not
Post by Paul Baker [MVP, Windows - SDK]
Post by Paul Baker [MVP, Windows - SDK]
part of the XML syntax which, I agree, seems a bit odd.
Maybe the person who wrote the first one knows what they're doing and
the
Post by Paul Baker [MVP, Windows - SDK]
Post by Paul Baker [MVP, Windows - SDK]
person who wrote the second one does not? I just don't know.
Paul
Post by James
Thanks Paul.
But my question is one URL produces output with lots of &lt; etc but
the
Post by Paul Baker [MVP, Windows - SDK]
Post by Paul Baker [MVP, Windows - SDK]
Post by James
other one does not. That is why I sent the complete code.
Also, the output says the encoding is utf-8 whereas the XMLDOM
supports
Post by Paul Baker [MVP, Windows - SDK]
Post by Paul Baker [MVP, Windows - SDK]
only
Post by James
utf-16.
Thanks.
James
in
Post by Paul Baker [MVP, Windows - SDK]
Post by James
Post by Paul Baker [MVP, Windows - SDK]
Oh, now I get it. You don't need any source code to prove a point,
because
Post by James
Post by Paul Baker [MVP, Windows - SDK]
it's nothing you're doing. Let me explain.
http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=MSFT
The response has a lot of instances of "&lt;" in it.
<?xml version="1.0" encoding="utf-8" ?>
<string
xmlns="http://www.webserviceX.NET/"><StockQuotes><Stock><Symbol>MSFT</Symbol
Post by James
<Last>29.77</Last><Date>11/9/2004</Date><Time>3:59pm</Time><Change>+0.49</C
hange><Open>29.43</Open><High>29.89</High><Low>29.35</Low><Volume>96263152</
Volume><MktCap>323.5B</MktCap><PreviousClose>29.28</PreviousClose><Percentag
Post by James
Post by Paul Baker [MVP, Windows - SDK]
Post by Paul Baker [MVP, Windows - SDK]
Post by James
Post by Paul Baker [MVP, Windows - SDK]
eChange>+1.67%</PercentageChange><AnnRange>24.01 -
29.89</AnnRange><Earns>0.78</Earns><P-E>37.54</P-E><Name>MICROSOFT
CP</Name></Stock></StockQuotes></string>
That's because Internet Explorer is parsing the XML and decoding the
&lt;
Post by James
to
Post by Paul Baker [MVP, Windows - SDK]
<.
You too need to parse the XML, for which you will need an XML
parser.
Post by Paul Baker [MVP, Windows - SDK]
Post by Paul Baker [MVP, Windows - SDK]
Post by James
MSXML
Post by Paul Baker [MVP, Windows - SDK]
is a free one available from Microsoft and included in recent
versions
Post by Paul Baker [MVP, Windows - SDK]
Post by Paul Baker [MVP, Windows - SDK]
of
Post by James
Post by Paul Baker [MVP, Windows - SDK]
Internet Explorer and Windows.
Paul
Post by James P
#include <windows.h>
#include <wininet.h>
#include <stdio.h>
void main()
{
FILE *fp = fopen("c:\\test.txt", "a");
if (!fp)
return;
BOOL InetCanConnect = FALSE;
HINTERNET hiOpen = NULL;
HINTERNET hiFile = NULL;
TCHAR webData[1024];
DWORD dwRead;
if (ERROR_SUCCESS != InternetAttemptConnect(0))
goto end;
if (NULL == (hiOpen = InternetOpen("TestApp",
INTERNET_OPEN_TYPE_PRECONFIG,
Post by James P
NULL, NULL, 0x0)))
goto end;
if (NULL != (hiFile = InternetOpenUrl(hiOpen,
"http://www.webservicex.net/RealTimeMarketData.asmx/Quote?Symbol=MSFT",
Post by Paul Baker [MVP, Windows - SDK]
Post by Paul Baker [MVP, Windows - SDK]
Post by James
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
NULL, 0, 0, 0)))
{
InternetReadFile(hiFile, webData, 1023, &dwRead);
InternetCloseHandle(hiFile);
webData[dwRead] = 0;
fprintf(fp, "%s\n", webData);
}
if (NULL != (hiFile = InternetOpenUrl(hiOpen,
"http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=MSFT",
Post by Paul Baker [MVP, Windows - SDK]
Post by Paul Baker [MVP, Windows - SDK]
Post by James
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
NULL, 0, 0, 0)))
{
InternetReadFile(hiFile, webData, 1023, &dwRead);
InternetCloseHandle(hiFile);
webData[dwRead] = 0;
fprintf(fp, "%s\n", webData);
}
InternetCloseHandle(hiOpen);
fclose(fp);
}
<?xml version="1.0" encoding="utf-8"?>
<QuoteList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.webservicex.net/">
<QuoteLists>
<Quote>
<Symbol>MSFT</Symbol>
<DateTime>19:59:57.416-05:00</DateTime>
<MatchedShares>17563379</MatchedShares>
<Price>29.34</Price>
</Quote>
</QuoteLists>
</QuoteList>
<?xml version="1.0" encoding="utf-8"?>
<string
-
E&gt;&lt;Name&gt;MICROSOFT
Post by James P
James
"Paul Baker [MVP, Windows - SDK]"
in
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
James,
Please give specific examples. I tried both and I saw nothing
odd.
Post by Paul Baker [MVP, Windows - SDK]
Post by Paul Baker [MVP, Windows - SDK]
Post by James
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
Paul
Post by James P
When I call
http://www.webservicex.net/RealTimeMarketData.asmx
Post by James
Post by Paul Baker [MVP, Windows - SDK]
the
Post by Paul Baker [MVP, Windows - SDK]
Post by James
Post by Paul Baker [MVP, Windows - SDK]
output
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
xml does not contain &lt; etc.
When I call http://www.webservicex.net/stockquote.asmx the
output
Post by Paul Baker [MVP, Windows - SDK]
Post by Paul Baker [MVP, Windows - SDK]
xml
Post by James
Post by Paul Baker [MVP, Windows - SDK]
has
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
these characters.
When I open it in IE, everything looks ok.
Any idea why and how I can get the output without those
characters?
Post by Paul Baker [MVP, Windows - SDK]
Post by James
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
Post by Paul Baker [MVP, Windows - SDK]
Post by James P
Thanks.
James
http://www.poovathummoottil.com
Continue reading on narkive:
Loading...