How in element get inner XML
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 5
- Joined: Thu Jun 07, 2012 10:37 am
How in element get inner XML
Hi,
How I can get Inner XML from the 'p' element:
Need some like this example result:
Do you have any idea for that problem?
Regards,
Ivan
How I can get Inner XML from the 'p' element:
Code: Select all
<p class="- topic/p ">Concept <xref class="- topic/xref " href="../../Maps/concept.dita">definition</xref>. 123<b class="+ topic/ph hi-d/b "><i class="+ topic/ph hi-d/i "/></b>
</p>
Code: Select all
Concept <xref class="- topic/xref " href="../../Maps/concept.dita">definition</xref>. 123<b class="+ topic/ph hi-d/b "><i class="+ topic/ph hi-d/i "/></b>
Regards,
Ivan
-
- Posts: 9449
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How in element get inner XML
Hi Ivan,
Please give us more details about what you want, do you want to obtain the content using the Author API or by applying an XSLT stylesheet over the original content?
From your previous posts I will assume you want to do this using Oxygen's API.
Here is a small code sample of copying the content of an AuthorElement to XML:
Regards,
Radu
Please give us more details about what you want, do you want to obtain the content using the Author API or by applying an XSLT stylesheet over the original content?
From your previous posts I will assume you want to do this using Oxygen's API.
Here is a small code sample of copying the content of an AuthorElement to XML:
Code: Select all
AuthorNode nodeAtOffset = authorAccess.getDocumentController().getNodeAtOffset(authorAccess.getEditorAccess().getCaretOffset());
if(nodeAtOffset.getType() == AuthorNode.NODE_TYPE_ELEMENT) {
AuthorElement elementAtOffset = (AuthorElement) nodeAtOffset;
if("p".equals(elementAtOffset.getName())) {
//Paragraph.
if(elementAtOffset.getStartOffset() + 1 < elementAtOffset.getEndOffset()) {
//The content of "p" as a document fragment
AuthorDocumentFragment content = authorAccess.getDocumentController().createDocumentFragment(elementAtOffset.getStartOffset() + 1, elementAtOffset.getEndOffset() - 1);
//We can also serialize it to XML like:
String contentAsXML = authorAccess.getDocumentController().serializeFragmentToXML(content);
//Then you can use that content and insert it in another context like:
//authorAccess.getDocumentController().insertXMLFragment(contentAsXML, offset);
//or
//authorAccess.getDocumentController().insertFragment(offset, content);
} else {
//Empty element
}
} else {
//We could go up to find the paragraph using
// elementAtOffset.getParent();
}
}
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service