Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 24889

Extensible Markup Language (XML) is a structured document format that defines human- and machine-readable encoding rules.

1 vote

Get Decimal value from XML response

If you have a look at the documentation on the various primitive types (i.e. Integer, Boolean, Decimal, etc...) you'll find that they have a valueOf() method that takes a string. The decimal class is …
Derek F's user avatar
  • 64.1k
1 vote

Parse String from XML

Looks to me like the big mistake in the XML parsing you're doing right now is in trying to extract data from the <field> tags, the innermost loop. … Yeah, they're on separate levels of the given XML structure, but it's not a stretch to treat them as a single, logical object. …
Derek F's user avatar
  • 64.1k
1 vote
Accepted

Validate xml file

If you're using ANT, you can set up a simple task that only performs a retrieve. An example, based off of the build.xml file that I use <target name="testRetrieve"> <mkdir dir="testRetrieve" /> …
Derek F's user avatar
  • 64.1k
0 votes

How to generated the below XMlStructure Based on list size?

You can generate XML using the classes in the Dom namespace, but there's an easier way (well, easier for me at least). You can use Visualforce to generate XML. <! … xml version="1.0" encoding="UTF-8" standalone="yes"? …
Derek F's user avatar
  • 64.1k
3 votes
Accepted

XML extract whole element block as string

Since XML isn't a regular language (regular expressions are meant to work on regular languages), we aren't left with too many other options beyond parsing. … Salesforce does provide an XML parser for us. I don't think it's as friendly or versatile as the JSON class, but it does break up an XML document into a structured data type. …
Derek F's user avatar
  • 64.1k
1 vote
Accepted

Parsing XML to get child nodes

Also, an "attribute" in XML is something contained inside of a tag in double quotes. E.g. <myXmlTag IAmAnAttribute="And I'm the attribute's value">. …
Derek F's user avatar
  • 64.1k
1 vote
Accepted

How do I read the following XML in Apex?

My preferred method of parsing XML is to use the Dom.Document and Dom.XMLNode classes along with creating different classes for each tag in your XML schema (at least until you get down to the very last … into an instance of Dom.Document If your XML is coming from a web callout, you can use HttpResponse.getBodyDocument() If your XML is in a plain string, you can use Dom.Document.load(myXMLString) Loop …
Derek F's user avatar
  • 64.1k
6 votes
Accepted

Can I prettify a XML string using Apex?

You would need to manually loop through all of the XML nodes and build the output string manually (so you would have the opportunity to insert line breaks). … xml version="1.0" encoding="UTF-8"?><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don\'t forget me this weekend! …
Derek F's user avatar
  • 64.1k
3 votes

Apex multi level apex parsing

My preferred approach to this is to have a class with a set of inner classes that mimic your xml schema. … The following is taken from the question and my answer on Convert Apex XML response into JSON Format? A portion of the xml from that question <?xml version="1.0" encoding="utf-8"? …
Derek F's user avatar
  • 64.1k
1 vote

Get REST API for a XML Response

arguments That's really all there is to it public void getTrackingStatus(String trackingNumber){ Http h = new Http(); HttpRequest req = new HttpRequest(); // url that returns the XML … doc.getRootElement(); // Create an instance of the class ShipmentStatus status = new ShipmentStatus(); // Call the method status.deserialize(root); } After you get the root XML
Derek F's user avatar
  • 64.1k
2 votes

How to Reorder XML tags

The XML that you're working with is pretty simple. … names mirror the names used // in the XML document as closely as possible. …
Derek F's user avatar
  • 64.1k
2 votes
Accepted

XML object creation. Is there any documentation?

More specifically, I think you're looking for the documentation on Metadata Types The documentation there will tell you the tags you can use to define a custom field, and there's usually some example XML
Derek F's user avatar
  • 64.1k
2 votes
Accepted

How to Create Records from XML Data?

The issue you're running into is that you're not getting deep enough into your XML hierarchy before trying to look for individual orders. … </Orders> </ListOrdersResult> </ListOrdersResponse> When you call doc.getRootElement(), you're being placed at <ListOrdersResponse> node in your XML tree. …
Derek F's user avatar
  • 64.1k
2 votes
Accepted

Unable to get all elements in List<Dom.XmlNode>

So instead of doing that, my preferred approach is to create small apex classes to mimic the structure of your XML (pretty much what the JSON2Apex tool hosted on Heroku does, but for JSON instead of XML … to generate some appropriate XML in your test to feed into the code being tested) …
Derek F's user avatar
  • 64.1k
2 votes
Accepted

Read a word document (Docx) and modify it in Salesforce

It's possible to zip and unzip things in Apex (Zippex), but the CPU and heap governor limits mean that only small files can be worked on Docx is a complex format (xml-based, uses the "open document format …
Derek F's user avatar
  • 64.1k