Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
extract XML
#2
the error is because you used x.ToString should be

x.FromString
 
Code:
Copy      Help
IXml x._create
IXmlNode e
x.FromString(s)
e= x.Path("workbook/datasources/datasource/column/@role")
str v2 = e.Value
out v2

full code to extract all the role values in column
Code:
Copy      Help
out
str s=
;<?xml version="1.0" encoding="utf-8"?>
;<!-- build 20183.18.1018.1932                               -->
;<workbook original-version="18.1" source-build="2018.3.0 (20183.18.1018.1932)" source-platform="win" version="18.1" xmlns:user="http://www.tableausoftware.com/xml/user">
;;<document-format-change-manifest>
;;;;<WindowsPersistSimpleIdentifiers />
;;</document-format-change-manifest>
;;<preferences>
;;;;<preference name="ui.encoding.shelf.height" value="24" />
;;;;<preference name="ui.shelf.height" value="26" />
;;</preferences>
;;<datasources>
;;;;<datasource caption="test" inline="true" name="federated.059vgdd0g7q5861coqvs91sv06g4" version="18.1">
;;;;;;<aliases enabled="yes" />
;;;;;;<column datatype="integer" name="[Number of Records]" role="measure" type="quantitative" user:auto-column="numrec">
;;;;;;;;<calculation class="tableau" formula="1" />
;;;;;;</column>
;;;;;;<column caption="Age" datatype="integer" name="[age]" role="measure" type="quantitative" />
;;;;;;<column caption="Gender" datatype="string" name="[gender]" role="dimension" type="nominal" />
;;;;;;<column caption="Name" datatype="string" name="[name]" role="dimension" type="nominal" />
;;;;;;<column caption="Rank" datatype="integer" name="[rank]" role="measure" type="quantitative" />
;;;;;;<layout dim-ordering="alphabetic" dim-percentage="0.473008" measure-ordering="alphabetic" measure-percentage="0.498715" parameter-percentage="0.0282776" show-structure="true" />
;;;;;;<semantic-values>
;;;;;;;;<semantic-value key="[Country].[Name]" value="&quot;United States&quot;" />
;;;;;;</semantic-values>
;;;;</datasource>
;;</datasources>
;</workbook>

IXml x._create
x.FromString(s)
ARRAY(IXmlNode) a
x.Path("workbook/datasources/datasource/column" a)
int i
for i 0 a.len
,IXmlNode attr=a[i].Attribute("role")
,str s2=attr.Value
,out s2


Messages In This Thread
extract XML - by ilcaa - 03-08-2019, 09:39 PM
RE: extract XML - by Kevin - 03-08-2019, 09:48 PM
RE: extract XML - by ilcaa - 03-08-2019, 10:29 PM
RE: extract XML - by Kevin - 03-08-2019, 10:36 PM
RE: extract XML - by ilcaa - 03-08-2019, 10:55 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)