Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a text node from xml directly #104

Closed
BenjaminGalliot opened this issue Mar 19, 2019 · 1 comment
Closed

Create a text node from xml directly #104

BenjaminGalliot opened this issue Mar 19, 2019 · 1 comment

Comments

@BenjaminGalliot
Copy link

Hello,

I would like to know how to create a TextNode directly from an XML string.
I did not find at all a way to do this: I get a whole Document or entities in my TextNode, it seems difficult or impossible to create a TextNode from a rich text string. A parsexml function which can return a TextNode (not only a Document) or an argument to specify to TextNode(content) that content is raw XML seem nice solutions.

I don't even find a workaround to insert inside a node text and other nodes from a rich text string.

For example:

using EzXML

text = """A <tag>simple</tag> word and a more <tag att="val">complex</tag> one."""

# Best expected way
# returns XMLError: Start tag expected, '<' not found from XML parser (code: 4, line: 1)
result_1 = parsexml(text)

# Another good way
# returns A &lt;tag&gt;simple&lt;/tag&gt; word and a more &lt;tag att="val"&gt;complex&lt;/tag&gt; one.
# it is expected but not the goal, an argument like "raw" would be nice.
result_2 = TextNode(text)

# Current step
# returns <?xml version="1.0" encoding="UTF-8"?><fake_tag>A <tag>simple</tag> word and a more <tag att="val">complex</tag> one.</fake_tag>
# but this is an EzXML.Document, not a TextNode, and the need to add fake tags around is messy (need to retrieve the tag of the parent…).
result_3 = parsexml("<fake_tag>" * text * "</fake_tag>")

Thank you.

@bicycle1885
Copy link
Member

Can you post a question at https://discourse.julialang.org/? The issue tracker is for issue tracking and not for questions. Mention me if you need my attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants