Parsing an XML file

Answered

Hi,

Please show me how I can read the content of an XML file located in the project's resources folder.

I am just learning to create my first plugin, so whatever details you can provide is much appreciated.

Thanks,

Tuan

0
3 comments

Hi Tuan,

first, you need to locate your file by calling LocalFileSystem.getInstance().findFileByPath().

Then load content like VfsUtil.loadText(VirtualFile).

 

1
Avatar
Permanently deleted user

Hi Dmitry,

Thank you for the suggestion. It works.  

I have another problem.  The xml file has a tag that has CDATA wrapped content.  I would like to removed the "CDATA" part from the actual data.  What is best way to do it?  Thanks.

0

You need to obtain PSI for your file, then locate the element you need, then remove it.

0

Please sign in to leave a comment.