Tag Info

New answers tagged

0

Since you added a Perl tag: perl -pE 'BEGIN{ $/ = "<key>servers</key>\n<dict>\n"; $content = `cat file.xml` } $_.=$content' your_input_file


0

Could you be a little more specific on the result you expect ? I'd use python3 and a PATH = '/My/Path/' FILE = 'MyFile.xml' for i, line in enumerate(open(PATH+FILE, 'r')): ... # since it's easy to catch a \n, and a line ends with one, so finding the lines you're looking for is easy but I need a better understanding of the result to continue


1

Would something like this work? sed '\|<key>servers</key>|{n \|<dict>| r other-file.xml }' file.xml


1

sed '/keys_line_1/,/keys_line_last/{/keys_line_last/{ h;s/unique_split_point.*//;r /path/to/insert/file x;s/.*unique_split_point//;G }}' sed is not exactly forgiving when it comes to requiring adjustments to an hypothesis. Everything sed does is a direct result of the thing it has just done, and so a very minor error in detail can drastically alter ...


3

You can do something like: awk '{print} $0 == "<dict>" && previous == "<key>servers</key>" { system("cat other-file.xml") } {previous = $0}'


1

Try this: grep "<TD>" yourfile.xml | awk -F "TD" '{gsub(">|</","",$0); print $2;}' the output will be: 51.9029244701 47.0082067303 grep select xml TD tag, awk use TD as separator and remove > and </ from $2 field. In order to select all node, try xslt transformation: <xsl:stylesheet version="1.0" ...


1

I wrote up a very simple Python script that will read in an xml file, and output its contents into another file: import sys inFile = open(sys.argv[1], 'r') outFile = open(sys.argv[2], 'w') read = True for i in inFile.read(): if i == '<': read = not read if read: outFile.write(i) if i == '>': read = not read ...



Top 50 recent answers are included