We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

(hml) StyleIdentifier depends on the element name and on its "Class" property

Hi,

In one of our projects, we need to know the name of the elements in an html file in order to know if an H1 element exists or not, the problem is that the library says that an element is StyleIdentifier.Heading1 only if the element is an H1 element without a class propery, in the other case it returns StyleIdentifier.User., It's interesting if we wanted to know more about the apparance of that element but in our project we need just to know its type.

Could you add please a property like discareCssStyle so the styleidentifier of the elements will depend only on their types and not on the property Class too ?

Thanks,

Hi Dimitri,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I am afraid it is not possible to add such property. Your suggestion is based on assumption that Aspose.Words DOM is based on HTML, but it is not. Aspose.Words was originally designed to work with MS Word documents, so Aspose.Words DOM is based on MS Word documents structure.

When you imports H1 element with specified class, Aspose.Words translates class to style and apply this style to the paragraph. That is why you get StyleIdentifier.User instead of StyleIdentifier.Heading1. But still, style created by Aspose.Words from class is based on “Heading 1” style. So you can try using code like the following to check whether the paragraph is H1:

private bool IsHeading1Paragraph(Paragraph paragraph)

{

if (paragraph.ParagraphFormat.StyleIdentifier == StyleIdentifier.Heading1)

return true;

else

return paragraph.ParagraphFormat.Style.BaseStyleName == "Heading 1";

}

Hope this helps. Please let me know if you need more information, I will be glad to help you.

Best regards,