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

  • Home
  • SEARCH
  • 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 6712319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:14:43+00:00 2026-05-26T08:14:43+00:00

We’re developing an socketserver who should receive xml. our specification said, a xml stream

  • 0

We’re developing an socketserver who should receive xml.
our specification said, a xml stream starts with
<?xml version="1.0" encoding="UTF-8"?><logmsg>

and end with
</logmsg>

Now, i try to add the XML-declaration line to my XML-Object, without success. A own written socket monitor shows only the <logmsg></logmsg>-Nodes. Also trace show similiar informations.

Is it possible to add the xml-declaration to an XML-Object overall?

logInfo = new XML('<?xml version="1.0" encoding="UTF-8"?><logmsg></logmsg>');
logInfo.@severity = value.serverity;
logInfo.@version = value.version; 

traces

<logmsg severity="2" version="0.1">
  <timestamp offset="120">
    1318939755
  </timestamp>
</logmsg>

and

var doc:XMLDocument = new XMLDocument('<logmsg></logmsg>');
doc.docTypeDecl ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
logInfo = new XML(doc);

has the same result, not exactly of course, but without the declaration line.

Can you help me?

  • 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-26T08:14:44+00:00Added an answer on May 26, 2026 at 8:14 am

    First the short answer: there is no way that I know of to get XML printed with prolog in AS3 (what you call declaration is, according to the specs, a prolog).

    More elaborate answer: XML class is responsible for the content of the XML document. Prolog is not a part of the document. XML classifies node as processing instruction, but this particular instruction is reserved and is not printable (this is a requirement of XML format that it will not appear inside the content). Other processing instructions, by default, aren’t added to the document at the time of parsing it, but you could add them by using XML.ignoreProcessingInstructions = false.

    Here you would need to be a bit more open-minded then programmers usually are, I don’t write this to bash random people 🙂 so, try to find some rationale for you, if you will. XML is the worst known yet very popular format for data storage and transfer. It was designed for presenting the data, but it is a bad tool for data exchange or storage. XML is extremely verbose and limited in a sense of type information and kinds of relations it can represent. On the other hand, it is too complex (think of DTD, namespaces and all such thing) for the humble results it can achieve. The good alternatives, especially for Flash exist, AMF3 is in all aspects superior to XML. There also exists Ptotocol Buffers implementation for AS3. So if you wanted to use an established and well-designed format, those are the options. If working off the local storage, SQLite may be bundled with AIR programs, which is a good option too.

    Few hints regarding your code:

    logInfo = new XML('<?xml version="1.0" encoding="UTF-8"?><logmsg></logmsg>');
    

    is a bad way to create instances of XML class. XMLs are same sort of objects as strings are. There is no justification for using new operator with XML. new operator is supported only so you could abstract object creation, but is not needed, when the class is known at compile time. Upon parsing, AS3 parser will eliminate redundant empty text nodes, so the code equivalent to the code above, but shorter and easier for the parser is:

    logInfo = <logmsg/>;
    

    XMLDocument class – this, if you insist on using XML may provide an answer. This class is in general simpler and more familiar to programmers who used the DOM API before. It also has less pitfalls in that you should know what E4X expressions compile to in order to write good performing code. XMLDocument is marginally faster for simple operations like attribute access or child node access. It is however more verbose. You can extend XMLDocument and make it print in any way you like, so printing the prolog would be a trivial task, if not yet implemented.

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

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.