Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6903125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:53:12+00:00 2026-05-27T07:53:12+00:00

I am trying to produce XML from erlang values and return that XML via

  • 0

I am trying to produce XML from erlang values and return that XML via socket.

So given,

Value = 2, Type = "3", Scope = anatom

I would like

<?xml version="1.0"?> 
   <result value=2 type="3" scope="anatom" />

What I get in this instance is escaped and has quotes around both the 2 and 3:

"<?xml version=\"1.0\"?><result value=\"2\" type=\"3\" scope=\"anatom\"/>"

If any of these values has a list, as in

Value = 2, Type = "3", Scope = [1,2]

I get something like [60,63,120,109, …] when I would like

<?xml version="1.0\"?> <result value=2 type="3" scope=[1,2]/>"

I have an xml formatting routine that looks like

format_return({ok, {V, T, S}}) ->
   Data =   {result, 
     [{value, V}, {type, T}, {scope, S}], 
     []},
   xmerl_ucs:to_utf8(xmerl:export_simple([Data], xmerl_xml)).

And its called by

 ...
 Reply = xml_formater:format_return(Reply),
 {ok, Reply, State}

The Reply, above, is passed back to my socket-generic-behavior which, in turn, results in

gen_tcp:send(Socket, io_lib:fwrite("~p~n",[Reply])),

Could some kind person please put me out of my misery?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:53:13+00:00Added an answer on May 27, 2026 at 7:53 am

    there seems to be two issues:

    A) this is not well-formed XML —

    <?xml version="1.0"?> <result value=2 type="3" scope=[1,2]/>
    

    so you won’t be able to generate it.

    B) the reason that you see the output as a list of integers is because of the relationship of lists and strings in Erlang – basically “abc” is equivalent to [$a,$b,$c] (or [97,98,99]). the erlang pretty-printer will display a list with all printable characters as the string equivalent. [1]

    your Scope variable [1,2] is equivalent to a string comprised of two non-printable characters (ascii 1, ascii 2). the xml routines don’t care that it’s non-printable. the output is displayed as a list of integers because it contains non-printable characters.

    if you change your Scope variable to [97,98] you’ll see that it displays as “ab” in the resulting xml.

    so.. if you are ok with the well-formed result —

    <?xml version="1.0"?> <result value="2" type="3" scope="[1,2]"/>
    

    your Scope variable needs to be the string “[1,2]” (or [ $[, $1, $,, $2, $] ] or [91,49,44,50,93]).

    [1] this is a simplification — there are dozens of others posts that explain this in better detail. https://stackoverflow.com/search?q=erlang+lists+and+strings

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to produce this XML statement (minus the formatting and specific values): <swatchcolor
I am trying to update several products that are fed from an XML file
I am trying to produce a nested XML document from a flat XML document
I'm trying to generate an XML output from a type in C#. I'm Using
I'm trying to produce a pretty simple XML schema for an XML similar to
I'm trying to produce a report that has multiple grouping but does not just
I'm trying to unmarshal a simple xml document from a public api from Convio.
I am trying to parse an XML response from Amazon's Product Advertising API, this
I'm trying to generate a XML document from the SQL Server 2005 database by
I'm trying to display the biggest image url returned from an xml result. So

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.