P paddy12309 Member Licensed User Aug 20, 2019 #1 So I'm using a very annoying system that's very specific about the way the XML is presented. Currently I have a handler serving this: B4X: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <CONTROLLER> <PARAMS> <FP ID="PIRTIMEOUT" MAX="7200" MIN="0" NAME="PIR Time Out" UNIT="SECONDS">1800</FP> <FP ID="STANDBYLEVEL" MAX="255" MIN="0" NAME="Standby Level">0</FP> <FP ID="ONLEVEL" MAX="255" MIN="0" NAME="On Level">222</FP> </PARAMS> </CONTROLLER> but need it to serve this: B4X: <?xml version="1.0" ?> <CONTROLLER> <PARAMS> <FP ID="PIRTIMEOUT" MAX="7200" MIN="0" NAME="PIR Time Out" UNIT="SECONDS">1800</FP> <FP ID="STANDBYLEVEL" MAX="255" MIN="0" NAME="Standby Level">0</FP> <FP ID="ONLEVEL" MAX="255" MIN="0" NAME="On Level">216</FP> </PARAMS> </CONTROLLER> its solely that top line that needs changing, the code generating the top version is as so: B4X: Dim props As Map props.Initialize props.Put("standalone", "yes") props.Put("{http://xml.apache.org/xslt}indent-amount", "2") props.Put("omit-xml-declaration", "No") 'props.Put("omit-encoding-declaration", "yes") props.Put("indent", "yes") 'resp.Write("Hello World") 'Log(xb.asString2(props)) Log("params params params") resp.Write(xb.asString2(props))
So I'm using a very annoying system that's very specific about the way the XML is presented. Currently I have a handler serving this: B4X: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <CONTROLLER> <PARAMS> <FP ID="PIRTIMEOUT" MAX="7200" MIN="0" NAME="PIR Time Out" UNIT="SECONDS">1800</FP> <FP ID="STANDBYLEVEL" MAX="255" MIN="0" NAME="Standby Level">0</FP> <FP ID="ONLEVEL" MAX="255" MIN="0" NAME="On Level">222</FP> </PARAMS> </CONTROLLER> but need it to serve this: B4X: <?xml version="1.0" ?> <CONTROLLER> <PARAMS> <FP ID="PIRTIMEOUT" MAX="7200" MIN="0" NAME="PIR Time Out" UNIT="SECONDS">1800</FP> <FP ID="STANDBYLEVEL" MAX="255" MIN="0" NAME="Standby Level">0</FP> <FP ID="ONLEVEL" MAX="255" MIN="0" NAME="On Level">216</FP> </PARAMS> </CONTROLLER> its solely that top line that needs changing, the code generating the top version is as so: B4X: Dim props As Map props.Initialize props.Put("standalone", "yes") props.Put("{http://xml.apache.org/xslt}indent-amount", "2") props.Put("omit-xml-declaration", "No") 'props.Put("omit-encoding-declaration", "yes") props.Put("indent", "yes") 'resp.Write("Hello World") 'Log(xb.asString2(props)) Log("params params params") resp.Write(xb.asString2(props))
Erel B4X founder Staff member Licensed User Longtime User Aug 20, 2019 #2 B4X: rest.Write(xb.asString2(props).Replace($"<?xml version="1.0" encoding="UTF-8" standalone="no"?>"$, $"<?xml version="1.0" ?>"$)) Upvote 0
B4X: rest.Write(xb.asString2(props).Replace($"<?xml version="1.0" encoding="UTF-8" standalone="no"?>"$, $"<?xml version="1.0" ?>"$))