Skip to content Skip to sidebar Skip to footer

Parse Variable To Xml

I would like to parse my variable 'valueStations2' into a xml string. Instead of a static sos:FeatureOfInterestId value (here e.g. 'stationname') I would like to have a dynamic par

Solution 1:

Try this:

 var valueStation2;

 var xmlString = "<?xml version='1.0' encoding='UTF-8'?><sos:GetFeatureOfInterestTimexmlns:sos='http://www.opengis.net/sos/1.0'service='SOS'version='1.0.0'xmlns:ows='http://www.opengeospatial.net/ows'><sos:FeatureOfInterestId>" + valueStation2 + "</sos:FeatureOfInterestId></sos:GetFeatureOfInterestTime>";

 var xmlParser = new DOMParser();
 var xmlDOM = xmlParser.parseFromString(xmlString, "text/xml");

Wrapping any variable with quotes will turn it into a string which is not what you're looking for.

Post a Comment for "Parse Variable To Xml"