Trim whitespace from parent element only

前端 未结 3 740
粉色の甜心
粉色の甜心 2020-12-21 12:31

I\'d like to trim the leading whitespace inside p tags in XML, so this:

Hey, italics and italics!

3条回答
  •  旧时难觅i
    2020-12-21 12:47

    This stylesheet:

    
        
            
                
            
        
        
            
            
        
    
    

    Output:

    Hey, italics and italics!

    Edit 2: Better expression (now only three function calls).

    Edit 3: Matching the first descendant text node (not just the first node if it's a text node). Thanks to @Dimitre's comment.

    Now, with this input:

    Hey, italics and italics!

    Output:

    Hey, italics and italics!

提交回复
热议问题