Comments (2)
Escaping within group works, without group tag, XML Etree will transform <br>
to <br>
and will fail to parse it as there is no closing tag.
Sample code:
data = """
Name:Jane<br>
Name:Michael<br>
Name:July<br>
"""
template = """
<group name="people">
Name:{{ name }}<br>
</group>
"""
# this works as well
# template = "Name:{{ name }}br"
# data = data.replace("<", "").replace(">", "")
# this did not work. fails with xml parsing error
# template = "Name:{{ name }}<br>"
# data = data.replace("<", "<").replace(">", ">")
parser = ttp(data, template)
parser.parse()
res = parser.result()
print(res)
# prints:
# [[{'people': [{'name': 'Jane'}, {'name': 'Michael'}, {'name': 'July'}]}]]
from ttp.
It worked indeed! Thanks, I guess I was doing something wrong
from ttp.
Related Issues (20)
- Hello everyone, how do I parse import_RT and export_RT in the following configuration file using TTP. HOT 1
- Question about parsing non hierarchical data HOT 4
- Config generation from TTP template HOT 1
- Group functions filter out tail match results HOT 2
- Incorrect behavior if text notstartswith '\n' and template with '_end_' indicates
- resuball functions will execution many times HOT 3
- Cannot parse identical keys in different groups HOT 2
- Record multiple variables from a single group? HOT 1
- matching irrelevant group HOT 1
- Using of group.to_int leads to errors HOT 3
- TTP KeyError while running macro HOT 1
- Handling a variable that conditionally appears in output to be parsed? HOT 2
- Add new method to TTP to emit template content HOT 1
- How to correlate/enforce previously matched attribute? HOT 2
- Incorrect "default" behavior in nested groups HOT 6
- Incorrect macro behavior in nested groups HOT 2
- Request: linenumber match function
- The asterisks at the end of the key_name are removed
- \1 in key_value used in group name path_string
- Not closing group match properly when matching lines appear in multiple places in config HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ttp.