B4J Question Trying to have a very basic XML Declaration with XML Builder

Discussion in 'B4J Questions' started by paddy12309, Aug 20, 2019.

  1. paddy12309

    paddy12309 Member

    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:
    Code:
    <?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:
    Code:
    <?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:
    Code:
    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))
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    rest.Write(xb.asString2(props).Replace($"<?xml version="1.0" encoding="UTF-8" standalone="no"?>"$$"<?xml version="1.0" ?>"$))
     
    Kiffi likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice