Jump to content

import XML


Recommended Posts

Hello

I am new to Evernote

Is it possible to import an XML file produced by a note program called Vault3?

The content of a very small example of such XML file with only two notes is the following (the two notes are called test1 and test2):

<?xml version="1.0" encoding="utf-8"?><Vault version="1.2" base64Encoded="true"><Item><Title>VGVzdDE=</Title><Text>dGVzdDE=</Text><Item><Title>dGVzdDI=</Title><Text>dGVzdDI=</Text></Item></Item></Vault>

Best

Link to comment
  • Level 5*

Unlikely, at least directly. Evernote's format, ENML (https://dev.evernote.com/doc/articles/enml.php), is a subset of XHTML (so it itself an XML subset), but it wouldn't understand such tags as <Vault> or <Item>. You'd need a program that translated it into ENML, in which case you could then import it using one of the desktop Evernote applications.

Link to comment
  • Level 5*

Well, ENML is a description of an Evernote note (text, tables, links, attachments, etc.). Your XML represents a description of something else. The first thing you need to do is identify what the elements of your XML represent, and how you want to translate them into things that Evernote does.I'd guess that you want some kind of table, but if you can't specify your XML domain, then yes, it is pretty much an impossible task.

Have you tried loading one of your XML files into a web browser? What does that look like? ENML is similar to HTML, so there's some rough equivalence there.

Link to comment
  • Level 5*
2 hours ago, Francus said:

I tried to search for a converter from XML to ENML, but it seems there are none.

That would be a custom conversion/import to Evernote     
It's do-able; I could easily write a simple script running on a Mac - about 15 minutes of work

Alternatively, convert your xml data to text files.    
Evernote can import text files using the filename as the note title

>>produced by a note program called Vault3

I did a quick look at Valult3, and see "exported in XML and PDF format"
Evernote can import PDF files using the filename as the note title

Link to comment
On 2/5/2020 at 11:56 AM, jefito said:

Well, ENML is a description of an Evernote note (text, tables, links, attachments, etc.). Your XML represents a description of something else. The first thing you need to do is identify what the elements of your XML represent, and how you want to translate them into things that Evernote does.I'd guess that you want some kind of table, but if you can't specify your XML domain, then yes, it is pretty much an impossible task.

Have you tried loading one of your XML files into a web browser? What does that look like? ENML is similar to HTML, so there's some rough equivalence there.

This idea seems interesting. changed the extension of a file to XML and opened it with firefox, but it gives errors:

XML Parsing error: Syntax error

Line number 1 column 1

SQlite format 3

Link to comment
On 2/5/2020 at 1:14 PM, DTLow said:

That would be a custom conversion/import to Evernote     
It's do-able; I could easily write a simple script running on a Mac - about 15 minutes of work

Alternatively, convert your xml data to text files.    
Evernote can import text files using the filename as the note title

>>produced by a note program called Vault3

I did a quick look at Valult3, and see "exported in XML and PDF format"
Evernote can import PDF files using the filename as the note title

I do not have a Mac, but I am using mostly linux. If you can write a script for me I can pay you (BITCOIN?).  In this case I can send to you a large file full of notes, to check if it works. Best

Link to comment
  • Level 5*
On 2/6/2020 at 8:45 AM, Francus1 said:

I do not have a Mac, but I am using mostly linux. If you can write a script for me I can pay you (BITCOIN?).  In this case I can send to you a large file full of notes, to check if it works. Best

I don"t need payment;  DM your xml file and I'll import it.
Let me know your email and I'll share a notebook with you

There were a couple of issues with the xml file
- the data was unreadable; it was encoded as base64
- the notes were structured in a hierarchy; Evernote does not support a note hierarchy
       Solution 1: Use tags and create a tag hierarchy
                           Problem: tags can be passed between accounts but tag structure can not be shared
         Solution 2: Show hierarchy in the note title, as in level1 - level2 - level3

edit: Here is the Applescript   xml.scpt

Part 1: Decoding the data in the xml file
            return do shell script "base64 -D <<<" & quoted form of str

Part 2: Identifying the XML structure
            <item>
                   <title>aaaaa</title>
                   ,<text xxxxx> aaaaa</text>
                    <item>                                         sub-item in hierarchy
                        <title>aaaaa</title>
                        <text xxxxx> aaaaa</text>   
                     </item> 
                </item> 

Part 3: Create Evernote Note  
             tell application "Evernote" to create note with text theText title theTitle notebook "XML" tags theTag

Part 4: Create Evernote Tag
           set theTag to make tag with properties {name:theTitle}
            
set parent of theTag to tag named "XML"

Part 5: Read xml file
             set theFile to "/Users/DTLow/Desktop/Test.xml"
             
set fileRef to open for access theFile
             
set theContents to (read fileRef)
             close access theFile
                  --sample <?xml version="1.0" encoding="utf-8"?><Vault version="1.2" base64Encoded="true">
                  --<Item><Title>aaaaa</Title><Text>bbbbb</Text></Item>
                  --<Item><Title>ccccc</Title><Text>ddddd</Text></Item></Vault>

Part 6: Parse the contents into items
                 set AppleScript's text item delimiters to "</Item>"
                 set theItemGroups to every text item of theContents
           set AppleScript's text item delimiters to "<Item>"
               
set theItems to every text item of theContents

Part 7: Parse the items into Title, Text and create Evernote note
              repeat with i from 2 to count of theItems
                   
set theItem to item i of theItems
                        --sample <Title>aaaaa=</Title><Text>bbbbb</Text></Item>
                   set theTitle to ParseDelim(theItem, "Title")
                   set
theText to ParseDelim(theItem, "Text")
                   tell
application "Evernote" to create note with text theText title theTitle notebook "XML"
             
end repeat

             on ParseDelim(theItem, theDelimiter)
                     --sample <Title>aaaaa</Title><Text>bbbbb=</Text></Item>,Title
                set AppleScript's text item delimiters to "<" & theDelimiter & ">"
                
set theParseItems to every text item of theItem
                      
--sample aaaaa</Title><Text>bbbbb=</Text>
                
set AppleScript's text item delimiters to "</" & theDelimiter & ">"
                 
set theParseItem to every text item of (item 2 of theParseItems)
                       
--sample aaaaa
                  
return item 1 of theParseItem
             
end ParseDelim

  • Like 1
Link to comment
  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...