Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi , I have the XML with the below structure...

XML
<TABLE NAME="PDF " PRIMARYKEYE="PDF ">
  <FIELD NAME="PNUMBER" FIELD="FieldTypeNumber" />
  <FIELD NAME="STATUS" FIELDTYPE="FieldTypeNumber" />
  <FIELD NAME="COMPANY" FIELDTYPE="FieldTypeNumber" />
<FORM NAME="PDF_DOC" TITLE="REGEN_PDF_DOC">
  <FORMFIELD NAME="POLICY_NUMBER" DBCOLUMNNAME="(SLECT POLICY_NUMBER FROM POLICY ,NOTE WHERE POLICY.POLICY=NOTE.TABLE_KEY)" />
  <FORMFIELD NAME="STATUS" DBCOLUMNNAME="(SELECT STATUS FROM STATUS_VALUE)" />
  <FORMFIELD NAME="COMPANY" DBCOLUMNNAME="(SELECT COMPANY FROM COMPANY WHERE COMPANY=20000)" />
  <FORMFIELD NAME="ENTERPRISE" />
  <FORMFIELD NAME="EFFECTIVE_DATE" />
</FORM>
<SEARCH NAME="SEARCHPDF" ORDERBYCLAUSE="PDF ">
  <JOIN TABLE="NOTATION" TYPE="LEFT" ON="PDF  CONDITION="ISNOTNULL" />
  <JOIN TABLE="PNUM" TYPE="INNER" ON="NOTE= POLICY" CONDITION="ISNOTNULL" />
  <SEARCHFIELD NAME="PNUMBER" LABEL="PNUMBER" />
  <SEARCHFIELD NAME="EFFECTIVE_DATE" LABEL="EFFECTIVE DATE" />
</SEARCH>
  </TABLE>



The xml content is available as an xelement by name table:


XElement table = this.filename.Root.Elements("TABLE").Single(W => W.Attribute("NAME").Value.Equals("PDF "));

Now im trying to list out the elements with the element nae as JOIN with the below syntax;

IEnumerable<xelement> joins = table.Element("SEARCH").Elements("JOIN");

but even after execution , the variable joins still has null value instead of 2 join elements . Can someone look into this?
Posted
Updated 25-Feb-14 7:07am
v2
Comments
idenizeni 25-Feb-14 14:26pm    
FYI, the XML you posted is missing the closing quote around the first JOIN element's ON attribute.

1 solution

C#
XElement table = xmlDoc.Elements("TABLE").Single(W => W.Attribute("NAME").Value.Equals("PDF "));
IEnumerable<XElement> joins = table.Elements("SEARCH").First().Elements("JOIN");
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900