Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
alexis
Partner - Specialist
Partner - Specialist

How can I parse XML string?

Hi

I 'm using a web service to return some data which I store in a variable.

This all works fine and the string contains a perfectly formed XML string but I need to display this string in a more readable form - is there a way that I can do that in QlkikView?

Thanks in advance..

Alexis

1 Solution

Accepted Solutions
m_woolf
Master II
Master II

See the attached qvw.

View solution in original post

6 Replies
m_woolf
Master II
Master II

Can you post an example of what the XML string looks like and how you want it to look?

alexis
Partner - Specialist
Partner - Specialist
Author

The string is:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetQuoteResponse

xmlns="http://www.webserviceX.NET/"><GetQuoteResult><StockQuotes><Stock><Symbol>STX</Symbol><Last>32.145</Last><Date>3/7/2013</Date><Time>3

:11pm</Time><Change>-

0.875</Change><Open>33.18</Open><High>33.20</High><Low>31.94</Low><Volume>4284727</Volume><MktCap>11.536B</MktCap><PreviousClose>33.02</Pre

viousClose><PercentageChange>-2.65%</PercentageChange><AnnRange>21.62 - 37.94</AnnRange><Earns>7.704</Earns><P-E>4.29</P-E><Name>Seagate

Technolog</Name></Stock></StockQuotes></GetQuoteResult></GetQuoteResponse></soap:Body></soap:Envelope>

I would like it either as something  like:

Symbol = STX

Last = 32.145

etc or

(as attached - could not add the image - in jpg or png - in this thread by the way - "Insert Image" just gave me a black screen with no prompts or drop-in facility..

m_woolf
Master II
Master II

See the attached qvw.

m_woolf
Master II
Master II

Can you save the xml as a file and use the Table files feature to load it?

I tried it with the string you sent, but the File Wizard returned an error, implying that the xml was incomplete.

alexis
Partner - Specialist
Partner - Specialist
Author

Hi mwoolf

I also tried to use subfield but could not achieve my objective, but using yoiur suggested "purgechar) solved the problem.

I know it's not the most efficient way, as I should store the purged version in another variable, but for now here is how I pull out the symbol

= 'Symbol = ' & subfield( purgechar(vXMLReceived,'/'), '<Symbol>',2)

Thank for your suggestions

Alexis

onkellepie
Partner - Contributor III
Partner - Contributor III

Hi,

you can also use TextBetween-Function in Script:

TextBetween(XML_Data, '<XMLTag>','</XMLTag>') as ColumnName

or as Formula in TextBox/ ListBox:

=TextBetween(XML_Data, '<XMLTag>','</XMLTag>')

Regards