B4J Question XML Displayed by by web-page

Discussion in 'B4J Questions' started by paddy12309, Jul 29, 2019.

  1. paddy12309

    paddy12309 Member

    Hi,
    any help much appreciated! I'm trying to get the XML builder to create an XML from some data else where in the program, it is currently being put on the webpage as this;
    Code:
    Collator Light Controller 57376 0988 MERCM04 17:06:12 17/04/02 0x0260 Yes Yes N/A N/A
    But I need it to be on the page as this:
    Code:
    <?xml version="1.0"?>

    -<CONTROLLER>

    <NAME>test 
    6</NAME>

    <TYPENAME>
    Case Controller (HT)</TYPENAME>

    <TYPENUM>
    57376</TYPENUM>

    <
    ID>0988</ID>

    <VER>MERCM04</VER>

    <TIME>
    17:06:12 17/04/02</TIME>

    <ALARMMASK>
    0x0260</ALARMMASK>
    -

    -<IO>
    -

    -<INPUTS>

    <STR VALS=
    "Yes | No" NAME="PIR Sensing" ID="PIRSENSING">N/A</STR>

    <STR VALS=
    "Yes | No" NAME="PIR Active" ID="PIRACTIV">N/A</STR>

    <FP NAME=
    "Lamp Level" ID="LAMPLEV" UNIT="" STEP="1.0" MAX="255.0" MIN="0.0">N/A</FP>

    <STR VALS=
    "System Ok | Function Test | Duration Test | Battery fault | Lamp Fault | Charging Failure | Inhibit Mode" NAME="E3 Status" ID="E3STAT">N/A</STR>

    </INPUTS>
    -
    <OUTPUTS> </OUTPUTS>
    -
    <STATES> </STATES>
    -
    <COMMANDS> </COMMANDS>

    </IO>

    </CONTROLLER>
    Heres my code:
    Code:
    Sub Handle(req As ServletRequest, resp As ServletResponse)
        mreq = req
        mresp = resp
        resp.ContentType = 
    "text/html"
        Subs.RespWriteStyle(resp)
        
    'Dim DeviceC As ResultSet = Main.EnergyDB.ExecQuery("SELECT E3Status FROM Device")
        
        
    Dim xb As XMLBuilder
        xb = xb.create(
    "CONTROLLER")
        xb = xb.e(
    "NAME").text("Collator").up
        xb = xb.e(
    "TYPENAME").text("Light Controller").up
        xb = xb.e(
    "TYPENUM").text("57376").up
        xb = xb.e(
    "ID").text("0988").up
        xb = xb.e(
    "VER").text("MERCM04").up
        xb = xb.e(
    "TIME").text("17:06:12 17/04/02").up
        xb = xb.e(
    "ALARMMASK").text("0x0260").up
        xb = xb.e(
    "IO")
        xb = xb.e(
    "INPUTS")
        xb = xb.e(
    "STR").attribute("ID""PIRACT").attribute("NAME","PIR Activity").attribute("VALS""Yes | No").text("Yes").up
        xb = xb.e(
    "STR").attribute("ID""PIRSENSIN").attribute("NAME","PIR Sensing").attribute("VALS""Yes | No").text("Yes").up
        xb = xb.e(
    "FP").attribute("ID""LAMPLEV").attribute("NAME","Lamp Level").attribute("MIN""0.0").attribute("MAX""255.0").attribute("STEP""1.0").text("N/A").up
        xb = xb.e(
    "STR").attribute("ID""E3 STAT").attribute("NAME""E3 Status").attribute("VALS""System Ok | Function Test | Duration Test | Battery fault | Lamp Fault | Charging Failure | Inhibit Mode").text("N/A").up
        xb = xb.up
        xb = xb.e(
    "OUTPUTS").up
        xb = xb.e(
    "STATES").up
        xb = xb.e(
    "COMMANDS").up
        xb = xb.up
        xb = xb.up
        xb = xb.up

        
        
    Dim props As Map
        props.Initialize
        props.Put(
    "standalone""Yes")
        props.Put(
    "{http://xml.apache.org/xslt}indent-amount""4")
        props.Put(
    "indent""yes")
        
    'resp.Write("Hello World")
        resp.Write(xb.asString2(props))
    Been stuck on this for too long, being new to b4j probably something silly!
    Again Thanks!
     
  2. DonManfred

    DonManfred Expert Licensed User

    A webview needs a html code to show.
    Looks like b4j webview is not able to show xml documents like some other browsers do (it is a feature of the browser in this case).

    Convert the xml so html and show the html.
     
  3. paddy12309

    paddy12309 Member

    I'll have a try, Thankyou!
     
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