Last post Oct 28, 2015 12:44 AM by Klein Zhang
Member
9 Points
31 Posts
Oct 27, 2015 08:30 PM|JohZant|LINK
What I am trying to get out of this response is to test out that the 'PropertySet' has under 'Fields' a 'field' with the FieldName 'BARCODE'.
XmlElement fields = (XmlElement)XmlResponse.What Goes Here;
The Above is the code that I have at the moment. I want to GetAttribute but I am not sure how I can get it to read the correct node.
Any help is appreciated.
What Happened Here!
I think I will try again.
Star
8460 Points
1445 Posts
Oct 28, 2015 12:44 AM|Klein Zhang|LINK
Hi JohZant,
JohZant What I am trying to get out of this response is to test out that the 'PropertySet' has under 'Fields' a 'field' with the FieldName 'BARCODE'.
JohZant The Above is the code that I have at the moment. I want to GetAttribute but I am not sure how I can get it to read the correct node.
According to your description, you'd like to get some nodes that meeting your above requirement from a xml file, isn't it?
I get a xml file from your code and try to get the meeting nodes using xpath, it works well.
Xml File.
<?xml version="1.0" encoding="utf-8" ?> <PropertySet Name="IX_DOCUMENT" Caption="Document Additional Meta Data" AppliesToDocuments="TRUE" AppliesToFolders="FALSE" AppliesToUsers="FALSE" SystemUseOnly="FALSE"> <Fields> <field FieldName="BARCODE" Caption="Barcode" DataType="CHAR" DataLength="50" Required="FALSE" ControlSize="50" ControlOrder="1" ControlType="TEXT BOX"/> <field FieldName="BOX_NUMBER" Caption="Box Number" DataType="CHAR" DataLength="16" Required="FALSE" ControlSize="16" ControlOrder="2" ControlType="TEXT BOX"/> <field FieldName="BOX_BARCODE" Caption="Box Barcode" DataType="CHAR" DataLength="32" Required="FALSE" ControlSize="32" ControlOrder="3" ControlType="TEXT BOX"/> <field FieldName="DATE_RECEIVED" Caption="Date Received" DataType="DATE" DataLength="8" Required="FALSE" ControlSize="12" ControlOrder="4" ControlType="TEXT BOX"/> <field FieldName="DATE_DOCUMENT" Caption="Date of Document" DataType="DATE" DataLength="8" Required="FALSE" ControlSize="12" ControlOrder="5" ControlType="TEXT BOX"/> <field FieldName="MEDIA" Caption="Media" DataType="CHAR" DataLength="50" Required="FALSE" ControlSize="50" ControlOrder="6" ControlType="COMBO BOX"></field> <field FieldName="EXTERNAL_REF1" Caption="External Ref 1" DataType="CHAR" DataLength="32" Required="FALSE" ControlSize="32" ControlOrder="7" ControlType="TEXT BOX"/> <field FieldName="EXTERNAL_REF2" Caption="External Ref 2" DataType="CHAR" DataLength="64" Required="FALSE" ControlSize="50" ControlOrder="8" ControlType="TEXT BOX"/> <field FieldName="PREVIOUS_DOC_ID" Caption="Previous Document ID" DataType="CHAR" DataLength="32" Required="FALSE" ControlSize="32" ControlOrder="9" ControlType="TEXT BOX"/> <field FieldName="PREVIOUS_DOC_NO" Caption="Previous Internal Doc No" DataType="NUMBER" DataLength="4" Required="FALSE" ControlSize="10" ControlOrder="10" ControlType="TEXT BOX"/> <field FieldName="PREVIOUS_FOLDER_ID" Caption="Previous Folder ID" DataType="CHAR" DataLength="64" Required="FALSE" ControlSize="50" ControlOrder="11" ControlType="TEXT BOX"/> <field FieldName="PREVIOUS_FOLDER_VOLUME" Caption="Previous Folder Vol No" DataType="NUMBER" DataLength="4" Required="FALSE" ControlSize="10" ControlOrder="12" ControlType="TEXT BOX"/> <field FieldName="PREVIOUS_SEC_LEVEL" Caption="Previous Security Level" DataType="NUMBER" DataLength="4" Required="FALSE" ControlSize="10" ControlOrder="13" ControlType="TEXT BOX"/> <field FieldName="PREVIOUS_ACCESS_LIST" Caption="Previous Access List" DataType="CHAR" DataLength="32" Required="FALSE" ControlSize="32" ControlOrder="14" ControlType="TEXT BOX"/> </Fields> </PropertySet>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Xml; namespace GridViewAppear { public partial class WebForm9 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Server.MapPath("~/XMLFile1.xml")); string AppID="BARCODE"; XmlNodeList xnP = xmlDoc.SelectNodes("PropertySet/Fields/field[@FieldName ='" + AppID + "']"); } } }
About Xpath, you could refer to the following links.
http://www.w3schools.com/xsl/xpath_examples.asp
http://www.w3schools.com/xml/xml_xpath.asp
I hope it's helpful to you.
Best Regards,
Klein zhang
Member
9 Points
31 Posts
Testing Element has a child element with a certain attribute
Oct 27, 2015 08:30 PM|JohZant|LINK
What I am trying to get out of this response is to test out that the 'PropertySet' has under 'Fields' a 'field' with the FieldName 'BARCODE'.
The Above is the code that I have at the moment. I want to GetAttribute but I am not sure how I can get it to read the correct node.
Any help is appreciated.
<div class="line" style="color: #000000; font-family: monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><response success="true" error=""></div> <div class="collapsible-content" style="margin-left: 1em; color: #000000; font-family: monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"> <div class="collapsible" id="collapsible1"> <div class="expanded"> <div class="line"><PropertySet Name="IX_DOCUMENT" Caption="Document Additional Meta Data" AppliesToDocuments="TRUE" AppliesToFolders="FALSE" AppliesToUsers="FALSE" SystemUseOnly="FALSE"></div> <div class="collapsible-content" style="margin-left: 1em;"> <div class="line"><DomainRestrictions Global="TRUE"/></div> <div class="collapsible" id="collapsible2"> <div class="expanded"> <div class="line"><Fields></div> <div class="collapsible-content" style="margin-left: 1em;"> <div class="line"><field FieldName="BARCODE" Caption="Barcode" DataType="CHAR" DataLength="50" Required="FALSE" ControlSize="50" ControlOrder="1" ControlType="TEXT BOX"/></div> <div class="line"><field FieldName="BOX_NUMBER" Caption="Box Number" DataType="CHAR" DataLength="16" Required="FALSE" ControlSize="16" ControlOrder="2" ControlType="TEXT BOX"/></div> <div class="line"><field FieldName="BOX_BARCODE" Caption="Box Barcode" DataType="CHAR" DataLength="32" Required="FALSE" ControlSize="32" ControlOrder="3" ControlType="TEXT BOX"/></div> <div class="line"><field FieldName="DATE_RECEIVED" Caption="Date Received" DataType="DATE" DataLength="8" Required="FALSE" ControlSize="12" ControlOrder="4" ControlType="TEXT BOX"/></div> <div class="line"><field FieldName="DATE_DOCUMENT" Caption="Date of Document" DataType="DATE" DataLength="8" Required="FALSE" ControlSize="12" ControlOrder="5" ControlType="TEXT BOX"/></div> <div class="collapsible" id="collapsible3"> <div class="expanded"> <div class="line"><field FieldName="MEDIA" Caption="Media" DataType="CHAR" DataLength="50" Required="FALSE" ControlSize="50" ControlOrder="6" ControlType="COMBO BOX"></div> <div class="collapsible-content" style="margin-left: 1em;"> <div class="collapsible" id="collapsible4"> <div class="expanded"> <div class="line"><options></div> <div class="collapsible-content" style="margin-left: 1em;"> <div class="line"><option value="Electronic"/></div> <div class="line"><option value="Paper"/></div> </div> <div class="line"></options></div> </div> </div> </div> <div class="line"></field></div> </div> </div> <div class="line"><field FieldName="EXTERNAL_REF1" Caption="External Ref 1" DataType="CHAR" DataLength="32" Required="FALSE" ControlSize="32" ControlOrder="7" ControlType="TEXT BOX"/></div> <div class="line"><field FieldName="EXTERNAL_REF2" Caption="External Ref 2" DataType="CHAR" DataLength="64" Required="FALSE" ControlSize="50" ControlOrder="8" ControlType="TEXT BOX"/></div> <div class="line"><field FieldName="PREVIOUS_DOC_ID" Caption="Previous Document ID" DataType="CHAR" DataLength="32" Required="FALSE" ControlSize="32" ControlOrder="9" ControlType="TEXT BOX"/></div> <div class="line"><field FieldName="PREVIOUS_DOC_NO" Caption="Previous Internal Doc No" DataType="NUMBER" DataLength="4" Required="FALSE" ControlSize="10" ControlOrder="10" ControlType="TEXT BOX"/></div> <div class="line"><field FieldName="PREVIOUS_FOLDER_ID" Caption="Previous Folder ID" DataType="CHAR" DataLength="64" Required="FALSE" ControlSize="50" ControlOrder="11" ControlType="TEXT BOX"/></div> <div class="line"><field FieldName="PREVIOUS_FOLDER_VOLUME" Caption="Previous Folder Vol No" DataType="NUMBER" DataLength="4" Required="FALSE" ControlSize="10" ControlOrder="12" ControlType="TEXT BOX"/></div> <div class="line"><field FieldName="PREVIOUS_SEC_LEVEL" Caption="Previous Security Level" DataType="NUMBER" DataLength="4" Required="FALSE" ControlSize="10" ControlOrder="13" ControlType="TEXT BOX"/></div> <div class="line"><field FieldName="PREVIOUS_ACCESS_LIST" Caption="Previous Access List" DataType="CHAR" DataLength="32" Required="FALSE" ControlSize="32" ControlOrder="14" ControlType="TEXT BOX"/></div> </div> <div class="line"></Fields></div> </div> </div> </div> <div class="line"></PropertySet></div> </div> </div> </div> <div class="line" style="color: #000000; font-family: monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></response></div>Member
9 Points
31 Posts
Re: Testing Element has a child element with a certain attribute
Oct 27, 2015 08:30 PM|JohZant|LINK
What Happened Here!
I think I will try again.
Star
8460 Points
1445 Posts
Re: Testing Element has a child element with a certain attribute
Oct 28, 2015 12:44 AM|Klein Zhang|LINK
Hi JohZant,
According to your description, you'd like to get some nodes that meeting your above requirement from a xml file, isn't it?
I get a xml file from your code and try to get the meeting nodes using xpath, it works well.
Xml File.
About Xpath, you could refer to the following links.
http://www.w3schools.com/xsl/xpath_examples.asp
http://www.w3schools.com/xml/xml_xpath.asp
I hope it's helpful to you.
Best Regards,
Klein zhang