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

XML > JSON: How do I 'intercept' processing of a specific node? #207

Open
blaasvaer opened this issue Sep 25, 2023 · 0 comments
Open

XML > JSON: How do I 'intercept' processing of a specific node? #207

blaasvaer opened this issue Sep 25, 2023 · 0 comments

Comments

@blaasvaer
Copy link

I need to strip a node for HTML tags ... how would I go about doing that? I've spent a couple of hours trying to 'figure' out the docs and trying all sorts of things by basically guessing, as the docs are clearly written by the same guy who wrote the lib. But I have had absolutely no success in using any of that information.

I have a node that looks like this:

<text>Ya da <grouptext>Ga Ba</grouptext>.</text>

I need to strip the text node for grouptext nodes (leaving out that 'level').

Now, from the docs I'm getting the impression I can add a custom function to the config:

var xmljs_options = {
	compact: true,
	spaces: 2,
	textFn: function ( value, parentElement  ) {
		// How can I access the text node on the parent element
		// and modify the value?
		if ( parentElement.nodeName? === 'text') {
			// strip tags and return modified value
		}
	}
};
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

1 participant