Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Another approach is to use a python macro. This replaces both WEBSERVICE and FILTERXML.

import uno
import xml.etree.ElementTree as ET
with open("G:/books.xml", 'r') as myfile:
    data = myfile.read().replace('\n','')
root = ET.fromstring(data)
titles = root.findall("book/title")

Another approach is to use a python macro. This replaces replace both WEBSERVICE and FILTERXML., as in this Python macro.

import uno
import xml.etree.ElementTree as ET
with open("G:/books.xml", 'r') as myfile:
    data = myfile.read().replace('\n','')
root = ET.fromstring(data)
titles = root.findall("book/title")

It could be improved by adding HTTP handling as well.

Another approach is to replace both WEBSERVICE and FILTERXML, as in this Python macro.example.

import uno
import xml.etree.ElementTree as ET
with open("G:/books.xml", 'r') as myfile:
    data = myfile.read().replace('\n','')
root = ET.fromstring(data)
titles = root.findall("book/title")

It could be improved by adding HTTP handling as well.

Another approach is to replace both WEBSERVICE and FILTERXML, as in this Python example.

import uno
import xml.etree.ElementTree as ET

def call_xpath_grab():
    titles = xpath_grab("C:/Users/MyID/folderpath/books.xml", "book/title")

def xpath_grab(filepath, xpath):
    # books.xml starts with open("G:/books.xml", empty space, which breaks the XML parser.
    # To fix this problem, this code reads the file into a string.
    with open(filepath, 'r') as myfile:
     data = myfile.read().replace('\n','')
 root = ET.fromstring(data)
titles = root.findall("book/title")
    return root.findall(xpath)

It could be improved by adding HTTP handling as well.