XML to Pike Converter Online

Paste any XML and generate Pike class declarations with explicit typed fields — string, int, float, array(T). Attributes are flagged in source comments so wiring up Parser.XML.Tree is unambiguous, all in your browser.

What is an XML to Pike converter?

An XML to Pike converter takes a real XML document and emits Pike class declarations with explicit typed fields that mirror the XML element / attribute tree. The OpenFormatter generator inspects every element and attribute, infers Pike types (string, int, float, array(T)), and produces a complete class hierarchy ready for the standard Parser.XML.Tree module.

XML differs from JSON in two ways your Pike model has to honour. First, XML has attributes on elements (<book id="bk101">) — these are read from node->get_attributes() rather than walking children. Second, XML allows arbitrary repetition; the generator picks array(T) for repeated children. Each field carries an inline comment marking attribute vs element so wiring is unambiguous.

Sample XML and the Pike class it generates

Input XML

<book id="bk101" lang="en">
  <title>Pike Programming</title>
  <year>2020</year>
  <price currency="USD">19.99</price>
</book>

Generated Pike

#charset utf-8
// Generated Pike data classes

class Price {
    string currency;  // attribute "currency"
    float text;       // text content
}

class Book {
    string id;        // attribute "id"
    string lang;      // attribute "lang"
    string title;     // <title>
    int year;         // <year>
    Price price;      // <price>
}

Notice id and lang are flagged as XML attributes, while title and year are child elements. The nested <price> generates its own class with one attribute and one text-content field — exactly what Parser.XML.Tree exposes via get_attributes() and value_of_node().

How to convert XML to Pike — 4 steps

  1. Paste your XML. A SOAP envelope body, a Roxen module config, an enterprise XML document — anything well-formed.
  2. Click Convert. The browser parses the XML and generates Pike classes for the full element tree.
  3. Review attribute comments. Confirm that // attribute markers match what you expect; rename fields if your style guide differs.
  4. Wire up Parser.XML.Tree. Copy the classes into your module and populate them by walking node->get_attributes() and node->get_first_element().

Typed Fields

Every field carries an explicit Pike type (string, int, float, array(T)) — the compiler catches mismatches when modules are loaded.

Attribute vs Element

XML attributes and child elements both become fields, but each carries an inline comment so your Parser.XML.Tree wiring uses the right accessor.

Client-Side Only

Your XML — including SOAP responses with credentials — is parsed in JavaScript on your machine. Verify in DevTools: zero network requests on Convert.

Common use cases

  • check_circleGenerate Pike classes from a SOAP service response
  • check_circleBuild typed Pike models for Roxen Webserver modules
  • check_circleConvert configuration XML to typed Pike classes
  • check_circleGenerate Pike types from an XSD-described XML file
  • check_circleCreate Pike unmarshalling models for legacy enterprise XML
  • check_circleBuild typed classes for SAML or WS-Security XML payloads
  • check_circleGenerate Pike models for sitemap.xml or robots.xml
  • check_circleConvert RXML / RSP-style XML templates to typed Pike data classes

Why client-side conversion matters

SOAP responses and enterprise XML often contain customer PII, API tokens, internal endpoint names, and database identifiers. Pasting them into a server-hosted converter is a compliance violation in most regulated industries. OpenFormatter parses the XML and generates Pike source entirely in JavaScript on your device — no upload, no logs, no cookies. Open DevTools → Network and confirm no requests fire when you click Convert.

More XML tooling

Validate, format, or convert XML to other languages — every tool runs locally in your browser.

Frequently Asked Questions

What is the XML support in Pike like?

Pike ships with the Parser.XML module — Parser.XML.Tree.simple_parse_input(string) returns a DOM-like Node hierarchy you can walk via get_first_element, get_attributes, and get_children. There is also Parser.XML.SloppyDOM for tolerant parsing of malformed XML and Parser.XML.NSTree for namespace-aware trees. Pike has been used in production at Roxen since the late 1990s, so the XML modules are mature and battle-tested.

How are XML attributes mapped to Pike fields?

Both attributes and child elements become typed fields on the generated Pike class, with attributes flagged by an inline "// attribute" comment. When you populate the class via Parser.XML.Tree, attribute values come from node->get_attributes() (a mapping(string:string)) while element values come from node->get_first_element("title")->value_of_node().

Why is Pike statically and dynamically typed?

Pike supports both styles: declared types (string, int, float, array) get compile-time checks, while mixed allows fully dynamic values. The generator emits explicit types for every field so the compiler catches mismatches early — but you can change any field to mixed if your XML carries genuinely heterogeneous content (e.g. union of string-or-array).

How are repeated elements like <tag> represented?

Repeated child elements become array(T) fields. Pike arrays are typed and dynamically sized; populate them by iterating node->get_elements("tag") and pushing each parsed value into the array with += ({ Tag(...) }).

Why class instead of mapping?

Pike mappings are open-ended hashmaps — convenient for ad-hoc data but they lose the per-field type information you want for XML modelling. Pike classes are closed records with typed members, equivalent to structs in other languages, and they support inheritance plus methods if you need to add helper functions later. Use a mapping when the XML has unbounded keys; use a class when the schema is fixed.

Does Pike enforce nullability?

Not by default. A Pike string is nullable (UNDEFINED is a valid value of any reference type). To require non-null, initialise the field at declaration with a default value or check for UNDEFINED in your constructor. The generator stays neutral — you decide which fields demand a value.

Is the XML I paste sent to your servers?

No. XML is parsed by the browser DOMParser and the Pike source is generated entirely in JavaScript on your machine. Open DevTools → Network and you will see no requests when you click Convert. Safe for SOAP responses and configuration files containing API keys or credentials.

How do I parse XML into the generated Pike class?

object root = Parser.XML.Tree.simple_parse_input(xml)->get_first_element(); Book b = Book(); b->id = root->get_attributes()["id"]; b->title = root->get_first_element("title")->value_of_node(); — repeated for each field. The Pike arrow operator (->) on objects is the equivalent of dot in C++/Java.

XML to Pike Converter Online — Free Mapping Generator