Skip to content

How to do XSD validation using XmlDocument's child(XmlElement). #76

Answered by jameslan
shreenu asked this question in Q&A
Discussion options

You must be logged in to vote

The setter of XmlDocument.root could move node from other document as its own root.

Example:

const original = XmlDocument.fromString('<container><content>hello</content></container>');

const content = XmlDocument.create();
content.root = original.get('/container/content');

console.log(content.toString());
console.log(original.toString());
<?xml version="1.0"?>
<content>hello</content>

<?xml version="1.0"?>
<container/>

This could extract a subtree as a document.

I think validating a subtree is a validate requirement and extracting to a new document could be a workaround for now.
We'll track and address this requirement in a separate issue.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by shreenu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants