Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Loading HTML content to Confluence page

yatindra kumar janghel October 11, 2021

Hi team ,

I have HTML file  and want to upload the  content of that HTML file in newly created confluence . I am able to create a confluence page using confluence.create_page command and able to add the static content to it . but whenver i m trying to read the contents of HTML page and trying to load it  i am getting below error .

Error parsing xhtml: Unexpected character ' ' (code 32) in content after '<' (malformed start element?).

Can you please help me with this issue 

HTML page looks like below

<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.
 This is going < to print
This is going > to print
</p>
</body>
</html>

 

---code

status = confluence.create_page('ABCD' ,#space,
                 'Report',#title
                  content ,#'This is the HTML body',,
                 parent_id=123456,### this is the pageid of the page under which new page 
                               will be created
                 type='page',
                 representation='storage',
                 editor='v2')

 

 

1 answer

0 votes
Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 11, 2021

I am going to guess that it is the format of your input file. I think you may need to strip the HTML and Body tags. The command syntax is as follows

confluence.create_page(space, title, body, parent_id=None, type='page', representation='storage', editor='v2')

There are also some examples here:

https://python.hotexamples.com/examples/atlassian/Confluence/create_page/python-confluence-create_page-method-examples.html  

yatindra kumar janghel October 13, 2021

@Bill Bailey This command can be used to create a page in confluence.Actual issue which i am facing the parsing the html content which is  having special charactor like "=,===,' " and some unwanted space before and after these character. there are libraries which can be used for parsing like beautiful soup, html parsar but these are restricated to  <.>.& charactors.

Can you please anything to resolve these issue

Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 13, 2021

High @yatindra kumar janghel , I am not a Python expert, but was just looking at what was published to figure out the error. I think if you just strip the html and body tags, the command would work. I would try that as an experiment to see if it is indeed the source of the error.

yatindra kumar janghel October 14, 2021

hi @Bill Bailey  Thanks for the response. by removing the html and body tags , i am able to copy the content to confluence page, lost the structure of the HTML page .Can you help me how i can maintain the structure of HTML page intact

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events