Parse text file with XSLT

后端 未结 2 1686
一整个雨季
一整个雨季 2021-01-05 03:15

I have a plain text file structured like this:

!ITEM_NAME
Item value
!ANOTHER_ITEM
Its value
...

Is it possible to get with XSLT a file sim

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-05 04:15

    If you can use XSLT 2.0 you could use unparsed-text()...

    Text File (Do not use the text file as direct input to the XSLT.)

    !ITEM_NAME
    Item value
    !ANOTHER_ITEM
    Its value
    !TEST_BANG
    Here's a value with !bangs!!!
    

    XSLT 2.0 (Apply this XSLT to itself (use the stylesheet as the XML input). You'll also have to change the path to your text file. You might have to change the encoding too.)

    
        
        
    
        
        
    
        
            
            
                
                    
                        
                    
                
            
        
    
        
            
                
                    
                                                        
                    
                    
                        
                            Error reading "
                            
                            " (encoding "
                            
                            ").
                        
                        
                        
                    
                
            
        
    
    

    XML Output

    
       Item value
       Its value
       Here's a value with !bangs!!!
    
    

提交回复
热议问题