Link to home
Start Free TrialLog in
Avatar of PeterInStingbert
PeterInStingbertFlag for Germany

asked on

XPATH Expression

Hi, i have a given XML (s. attached File)

it includes an Export of a Database-Schema
but the structure is "oversimplified"
Just nested Properties and Property Tags.
The Property-Tags named by Attribute PropertyName
Parent-Property further specified by  Attribute MetaType (e.g. DbTable, DbColumn)


I Need different xpath queries to select nodes e.g.

all Property-Nodes with MetaType = "DbColumn" and with Primarykey=true  and ColumnType=1


Thank you
Peter
test.xml
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

//Property[@MetaType='DbColumn'][normalize-space(Properties/Property[@PropertyName='IsPrimarykey']) = 'true'][normalize-space(Properties/Property[@PropertyName='ColumnType']) = '1']

Open in new window


But there is none in the example XML

for the primary key columns, columnType is 0 or 3 in this example
Avatar of PeterInStingbert

ASKER

Sorry, my mistake  ColumnTyp = 3 is correct.
Thankl you
But in the result is only one record.
I Need all records, including the parent tag

e.g.

//Property[@MetaType='DbColumn'][normalize-space(Properties/Property[@PropertyName='AllowNull']) = 'false']

Open in new window

should give 3 records


and in your manner
//Property[@MetaType='DbColumn'][normalize-space(Properties/Property[@PropertyName='IsPrimarykey']) = 'true'][normalize-space(Properties/Property[@PropertyName='AllowNull']) = 'false']

Open in new window

should give 2 records
"should"... it does not
so you need to be more precise on what you need
The XPath I sent does exactly what you asked for
So I assume the instructions were not precise enough
Tell me what exactly you need from the XML
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I tested on an xpath-Tester site....

Now i write my own c# based test-app.
It works.

sorry, please don't be angry with me.

Thanks
Peter
why angry?
don't worry,
it is a matter of finding where the issue is... we found it, so both happy :-)