Problem loading an xml string containing xml data into XML document

 Hi all,

I have a problem loading an xml string containing xml response data returned by other server(spatial server) into XML document some times becoz the returned xml response contains special chars like <, >, ', etc.Is there any way to parse this XML response string before loading into XML document.

0
bharathreddyd
6/29/2007 10:16:06 AM
asp.net.xml-datasource 7181 articles. 0 followers. Follow

3 Replies
1931 Views

Similar Articles

[PageSpeed] 50
Get it on Google Play
Get it on Apple App Store

Hi Bharath,

if you can't find a ready made one you can write one yourself.

Parse the string that you get for the elements that it would contain and inject the CDATA element between them to allow special character.

example if you have a string

<childNode>
This contains special character < and  &
</childNode>

Your parsed string would now become

<childNode>
<![CDATA[
 This contains special character < and  & ]]>
</childNode>

You can now load the xml in Xml Document class.

Happy programming,
Anton

0
antonpious
6/29/2007 1:17:27 PM

Hi fren,

I mean to say , i send  

 

Dim strSpatialxmlstring As String (this is query to spatial server to return few addresses matching criteria)
        strSpatialxmlstring = "<?xml version=""1.0"" encoding=""UTF-8""?>"
        strSpatialxmlstring &= "<ARCXML version=""1.1"">"
        strSpatialxmlstring &= "<REQUEST>"
        strSpatialxmlstring &= "<GET_FEATURES featurelimit=""100"" beginrecord=""0"" outputmode=""xml"" geometry=""true"" envelope=""true"" compact=""false"">"
        strSpatialxmlstring &= "<LAYER id=""" & intLayer & """ />"

        strSpatialxmlstring &= "<SPATIALQUERY   where=""Upper(" & strstreetfield & ") LIKE '" & Street.ToUpper.TrimEnd.TrimStart & "%' ""></SPATIALQUERY>" 'AND Upper(TYPE)='DR' and POSTAL_R = '93010'  "">"></SPATIALQUERY>"


        strSpatialxmlstring &= "</GET_FEATURES>"
        strSpatialxmlstring &= "</REQUEST>"
        strSpatialxmlstring &= "</ARCXML>"   

Dim strSpatialfinal as string
 strSpatialfinal = con.Send(strSpatialxmlstring )

this strSpatialfinal string contains a xml response string from the Spatial server which some some times throws bad xml response which might contain unclosed tags or special chars.If we directly give to xmldoc it fails.thats the prob..I need to parse the xml string response???how to do it??

Dim xmldoc as xmldocument

 xmldoc.loadxml(strSpatialfinal)

 

0
bharathreddyd
7/2/2007 6:16:31 AM

Hi  bharathreddyd ,

Since you have special characters inside xml tags processor would report *unclosed tags error*.

There are two approaches:

1. *Inject the CDATA element between them to allow special character.* as suggested by Anton.

   For details see:  http://msdn2.microsoft.com/en-us/library/ms256076(vs.80).aspx

2. Encode *<*    *>* tags using HtmlEncode.

   For details see:  http://msdn2.microsoft.com/en-us/library/73z22y6h.aspx

 


NOTE:If you find my response contains a reference to a third party World Wide Web site, I am providing this information as a convenience to you.Microsoft does not control these sites and has not tested any software or information found on these sites; therefore,Microsoft cannot make any representations regarding the quality,safety, or suitability of any software or information found there.
__________________________________________________

Sincerely,
Young Fang
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
0
Young
7/3/2007 5:48:42 AM
Reply:

Similar Artilces:

XML in, XML out
Hi All (and a happy holiday to those that will get a break), I am trying to read in an XML file of addresses. I need to remove all the address data from the file where code =~ /^000/ (there are none in the example data below). I need to reproduce that data 'as is', so I need to honour the tag structure, although the order of the tags doesn't need to be honoured. I have been trying to use XML::Simple and I had a go with XML::Smart but I haven't been able to get the results I want. My best effort is below (with XML::Simple). There are a couple of differences ...

XMl to XML
Hello,   I retrieved an XML from the dataset which retrieves data from the table in the database. I need to present the data  in a different structure. Is XSLT the way or are there any other options. please let me know. Thanks!! Yes XSLT is a good choice to convert xml file to other forms. You can take a look at XSLT Tutorial.Sincerely,Young Fang...

WebControls &amp; XML problem: cannot load data from xml file (i think that is the problem...)
Hi all i'll expose my problem. i have installed framework 1.1 and the SDK and it didn't work. I have uninstalled them and reinstalled 1.0 versions. i have downloaded the WebControls installation file and run it, i have build the Microsoft.Web.UI.WebControls.dll and located in a "bin" folder in my folder application (wwwroot/sampleapp/) and i have placed the webctrl_client folder in my wwwroot folder (i have also tried to duplicate that folder EVERYWHERE in my harddisk catched by sadness!!! O_o). Then i have done the following aspx page: ******************************...

Converting XML string into XML Document
I am calling a web service which returns an XML string containing numerous fields which I need to obtain the values against.I have done the following so far, in an effort to retrieve the values within the XML, but it appears that despite loading this XML string into an XMLDocument, the entire string is assigned as the InnerHTML of the XMLDocument, but there are no nodes/entities etc.// Extract return fields from the Web Service (result is the xml string response from the webservice).StringReader sr = new StringReader(result);XmlDocument xmlDoc = new XmlDocument();xmlDoc.Load(sr);// These are...

LOADING XML FILE USING XML BULK LOAD problem
Im trying to load a xml file to 2 tables Here is the xml file <?xml version="1.0" encoding="utf-8"?><Job>  <jobheader>    <Version>1.0</Version>    <fkUserId>10</fkUserId>    <UID>12344-234234993-4890033-123</UID>    <ProfileId>1</ProfileId>    <OutputFormatId>1</OutputFormatId>  </jobheader>  <stateData>      <State>PA</State>      <State>NJ<...

XML::Parser XML::DOM XML::XSLT
------_=_NextPart_001_01C6E0D0.3E27D77A Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Hi Craig and fellow VMS Perlers, You last wrote about this Fri 3/16/2001 11:24 AM, not counting your very helpful comments on Eisner/Decuserve more recently. One of my colleagues sent me an email requesting that I make XML::XSLT=20 available on VMS. perl 5.8.6, VMS 7.3-2, DECC 7.1 latest ACRTL (version 3) on Alpha XML::XSLT (version 0.48) depends on XML::Parser (version 2.34). This depends on expat (version 2.0.0). I built expat a...

problem in converting an xml string back to xml
Hi,When I try to convert an xml string back to XmlDocument I am getting an XmlException saying “The root element is missing”. This exception occurs when the xml is not well formed or if the xml is blank. But here the xml string starts like below:"<?xml version=\"1.0\" It is well formed but I am wondering if this exception is caused by the back slashes. These back slashes were added automatically when I converted the xml to string.I am using the following code to convert the xml String back to XML://XMLRequest is a string which contains the xml XMLRequest = XM...

reading data from xml service or xml datasource
Hi, I'm trying to figure out a way to import data (but not export to, I'm just trying to get their news section) from an external db (SqlServer 2000 or 2005) to a gridview and detailsview on my site (resides at a web host). I spoke to the organisation that owns the external db and they are willing to look into several solutions, whitout giving out their db password etc. Not suprisingly, I was reccomended using a web service. However, I believe I need to install stuff in order to enable one, and so, it won't be able for me (I guess), because of my web host's limitations. Instead, I am now t...

Xml Convert string to xml
Hi I have a save the file xml to database as TEXT, I would have to read the field of the db, and reading the tag of the xml Can Help me Thank's...

How to select Xml as Xml?
If I select Xml nodes like this from sql server; select xmlData.query('//Field[@F = "True"]') as extendedInfo from.... ..how to loop through the items in C#? I can't cast it to a System.Xml.XmlNodeList..? You can use the XmlDocument class.  There's a Load method and a LoadXml method.  One of these should get you what you want, after which you can select nodes as you need.C# <---> VB.Net Translator mm8: If I select Xml nodes like this from sql server; select xmlData.query('//Field[@F = "True"]') as extendedInfo from.... ...

Problems writing to an XML file
I'm brand new to using XML (in fact this is my first project), so bear with me, I may need a little hand-holding. I'm trying to create a page which simply adds data to an existing xml file. Ultimately it will add the data from a form, but to keep things simple, I've been simply using pre-defined values. Originally I was able to get the script to write the xml exactly as I needed, however it would simply overwrite the existing file every time it was accessed. This is unacceptable, as it will be used to add data to one file, sort of like a mini database. So after much pain and gnashi...

Transform XML to XML
I've been trying to transform an XML document to another XML document. The original document is very large (6megs) and the application that needs to use it only needs a fraction of the data. I'm trying to take this mother-of-all XML documents and filter out unwanted nodes. I could probably do this very easily with code by running a few XPath Queries against the document, and placing the results in a new document...however...I have an interest in learning how to do this with XSL. In the past, I've done some pretty basic XML to HTML transformation ans that worked out well. This ti...

sort xml in xml
Hi, How I can sort xml file in xml with VB.NetThanks,<?xml version="1.0" encoding="ISO-8859-1" ?>  <Liste>   <Form Famille="Administration" idXhtml="" idOffice="31574" nom="ADM" desc="" />   <Form Famille="Admini" idXhtml="" idOffice="31708" nom="ADM- 54 (2000)" desc="" />   <Form Famille="communication" idXhtml="" idOffice="31709" nom="ADM- 133 (2000)" desc="" />   <Form Famille="Admini" idXhtml="" idOffice="31710" nom="ADM- 9 (2000)" desc="" />   <Form Famille="Admini" idXhtml="" idOffice="31711" no...

XML is returned from database but how do I load it into a xml document object?
Hello, I was doing so well and now fallen at the last hurdle!  I have managed to finally get XML out of SQL Server, and by pasting the text into an XML file, I have written a procedure that loops through an XML document and displays my report. I now want to populate my XML document with the string of XML returned from the database when I call the procedure as oppossed to using an XML file.  This is where I have got stuck: By placing the results of the stored procedure into a ds, my application falls apart. What do I need to do in order to call the XML from my database ...

Web resources about - Problem loading an xml string containing xml data into XML document - asp.net.xml-datasource

Fake Video? Woman Steals From Child On Black Friday: ‘Why Are You Being So Aggressive?’
There are Black Friday videos being uploaded to YouTube that show shoppers behaving badly. One video, named “Lady steals from KID! Black Friday ...

Trump outdoes himself with this mocking/not mocking of a disabled reporter.
My take on this story ? Trump — seeming free and wild — somehow hits an absolutely precise line. It's so precise that I want to credit him with ...

Man jumped White House fence while whispering 'let's do this' while Obamas were still inside
WASHINGTON — A man draped in an American flag climbed over the fence at the White House on Thursday, prompting a lockdown as the first family ...

Kremlin says Turkey's Erdogan requests meeting with Putin in Paris
Reuters Kremlin says Turkey's Erdogan requests meeting with Putin in Paris Reuters MOSCOW Russia said on Friday that Turkish President Tayyip ...

French singers pay emotional tribute to Paris Attack victims 'when we have only love, to talk to guns' ...
"When we have only love, to talk to guns, and just a song to convince a drum." "So, having nothing, but the strength to love, we will have in ...

Big Balloons, Heavy Security for NYC Thanksgiving Parade
Big balloons, heavy security for NYC Thanksgiving parade; St.

Sony Working on App to Stream PS4 Games on Mac and PC
Sony executive Shuhei Yoshida has announced on Twitter that the company is working on an official Remote Play app for Mac and PC, enabling users ...

Similarities to Jim Jones and the Cult of Climate Change
Guest opinion by Arkady Bukh, Esq The apocalypse of an alleged climate change shares many of Jones’ cult-like qualities. Jim Jones, the People’s ...

Social Elites Slammed on Pope Francis’ Kenya Visit
Pope Francis’ Kenya visit concluded Friday with a visit to Kangemi, a poor shanty town on the outskirts of Nairobi. The visit to such a poor ...

LG bets $8.7 billion you'll want a TV with rich OLED colors
TVs with OLED display technology remain rare, but the South Korean company expects a gargantuan new manufacturing plant will help spread the ...

Resources last updated: 11/27/2015 3:45:56 PM