Hot answers tagged

19 votes
Accepted

Import iTunes xml data and convert it into a dataset or table

We can start by importing the file as an XMLObject: ...
user avatar
  • 67k
15 votes

CSS Selectors for Symbolic XML

I think Mathematica with its symbolic and pattern-matching capabilites is well suited to tackle parser and tree searching. It's better to check, though. Here are two quick proof-of-concept of the toy ...
user avatar
  • 763
9 votes

Efficient structure for XML manipulation

I'm going to focus on the convenience part of the question. jsoupLink can work well for a lot of situations. Let's say, for example, that we want to parse RSS. RSS is an XML format, so we can do it ...
user avatar
  • 68.7k
8 votes
Accepted

How to validate an XML file against xsd in Wolfram language?

JLink` Here is a solution that uses JLink` to leverage Java's support of XML Schema: ...
user avatar
  • 67k
6 votes
Accepted

Importing malformed XML: Import[... "XMLObject"] vs ImportString[..., "XML"]

I am using Mathematica 8.0.4 and have no URLFetch command, so I have used Wget to download this 5915505 bytes file: ...
user avatar
6 votes
Accepted

Converting between XML and JSON?

It's not clear how XML can be converted to JSON in a general way, because how would one deal with attributes? You happen not to have attributes in your XML, but that's just a special case. Luckily, ...
user avatar
  • 68.7k
6 votes
Accepted

XML, select several values

You can capture all consecutive events like this: ...
user avatar
  • 17.9k
5 votes

Markdown parser in Mathematica

To get the ball rolling, here's my incomplete parser. And here's a minimal markdown sample. This is what my markdown parser makes of it, used like so: ...
user avatar
  • 45.4k
5 votes

Pulling Out Values from JSON Association

First of all, I think you can make your life a bit easier by using RawJSON as input format specification. It basically makes Mathematica use Associations where appropriate when importing JSON. ...
user avatar
5 votes

Is it possible to grab all the links at once on a webpage?

If you look at the URL that you found, you'll notice a parameter pn. If you change this parameter you get another set of t-shirts. To get all t-shirts you need to ...
user avatar
  • 68.7k
5 votes

Unwanted extra spaces at HTML tag boundaries when using ImportString

I don't know what causes the issue (which looks like a bug to me), but I generally find the best way to deal with exerting control over Import not doing quit the ...
user avatar
  • 17.8k
5 votes
Accepted

How can I set id attribute of elements when I export an SVG file?

First, let me tell you that following your code my output is quite different. g=Graphics[{Disk[{-1,0},1/2],Rectangle[]}]; ExportString[g,"SVG"] Output ...
user avatar
  • 1,569
5 votes

Finding relevant parts in XML document

In this case what you want is simple/regular enough that you can define the XMLElement etc. as functions that return what you want inside a ...
user avatar
  • 213k
5 votes
Accepted

Adding MathML export rules

Expanding my comment into a concrete answer: Using GeneralUtilities`PrintDefinitions to look at the functions responsible for the ...
user avatar
  • 23.4k
4 votes
Accepted

Finding relevant parts in XML document

This seems to be a normal way to extract the data:- ...
user avatar
  • 29.1k
4 votes

Import iTunes xml data and convert it into a dataset or table

Had to add the "ReadDTD" -> False option to ...
user avatar
  • 258
4 votes
Accepted

Convert `FullForm` to XML Structure and back

I think I can understand this latter version of the question better. Unfortunately though I don't speak jquery, so I don't really understand your example, therefore I will leave the applications to ...
user avatar
  • 58.3k
4 votes
Accepted

Whitespace is lost during MathML -> XMLElement conversion

Try ExportString[ImportString["<mtext> </mtext>", {"MathML", "XMLElement"}, "NormalizeWhitespace" -> False], "XML"] From XML/tutorial/ImportingXML....
user avatar
  • 936
4 votes
Accepted

Void elements / self closing tags export to HTML

This problem appears to be localized to HTMLFragment, possibly because HTML specifications before HTML5 did not use self-closing tags like XHTML and XML always have....
user avatar
  • 68.7k
4 votes

Import from url question -- "Cannot import data as Graph6 format"

To make this work, you need to specify the format. There is no "XMLObject" format. "XMLObject" is an import element for the <...
user avatar
  • 224k
4 votes

Repeated pattern in XMLElement

Cases[xml,XMLElement["forename" | "surname", _, x_] :> x, \[Infinity]] (* {{"Adrian"}, {"Adgar"}, {"Babar"}, {"Barbados"}, {"Bode"}, \ {"Charly"}, {"Chimp"}} *) ...
user avatar
4 votes

Efficient structure for XML manipulation

C.E.'s answer is probably the best, relying as it does on a well-constructed Java library with serious people behind it, but I thought it'd be nice to have a pure Mathematica solution as well, so I ...
user avatar
  • 45.4k
4 votes
Accepted

Subsequence Search

I don't know how extensible this is, but it works for your case, ...
user avatar
  • 62.6k
4 votes

Converting between XML and JSON?

I've not been involved with XML lately, but I used to (re)define XMLObject and XMLElement to process an XML structure. It's ...
user avatar
  • 213k
3 votes
Accepted

Can I use StringExpression or RegularExpression to manipulate Symbolic XML?

You should use Condition with StringMatchQ: ...
user avatar
3 votes
Accepted

Include comments in exported XML file

We can use the construction XMLObject["Comment"]["..."]. This is described in detail in this tutorial. For example... ...
user avatar
  • 67k
3 votes

Convert `FullForm` to XML Structure and back

Combining Michael E2's answer to another question, that redefines XMLElement, and MarcoB's answer above, here is another approach. To get the Wolfram expression of the messy XML that will recreate ...
user avatar
3 votes
Accepted

Extracting blocks of "adjacent" XMLElements

...
user avatar
3 votes

Repeated pattern in XMLElement

A minimal example showing why the original Cases doesn't work, ...
user avatar
  • 62.6k
3 votes
Accepted

Error importing JSON in 11.3 (worked in 11.2)

There is a way to fix the invalid UTF8 using: FromCharacterCode[ToCharacterCode[_String, "UTF-8"]] Then use ImportString on ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible