Note that there are some explanatory texts on larger screens.

plurals
  1. POvb.net and xml select node based on innertext of previous node
    primarykey
    data
    text
    <p>My XML comes in like this:</p> <pre><code>&lt;Document type="ContentPage"&gt; &lt;Fields&gt; &lt;Field name="FaqCategory" type="dropdown" title="Select Category:" index="FaqCategory" list="\Lists\FaqCategory" required="true"&gt; Online Experience &lt;/Field&gt; &lt;Field name="FaqSubCategory" type="dropdown" title="Select Sub Category" list="\Lists\FaqSubCategory" required="true"&gt; Using the site &lt;/Field&gt; &lt;Field name="FaqQuestion" type="text" title="Enter FAQ Question:" required="true"&gt; How do I find articles on the site? &lt;/Field&gt; &lt;Field name="FaqAnswer" type="richtext" title="Enter FAQ Answer:" editorProfile="Advanced" required="true"&gt; Answer to: How do I find articles on the site? &lt;/Field&gt; &lt;/Fields&gt; &lt;Placeholders /&gt; &lt;Indexes /&gt; </code></pre> <p></p> <p>These are all in an array of XML objects, I need to sort through the array and set up (obviously) a FAQ section for this site. The problem I am having is that since this is not 1 xml document but a collection of xml documents, I am having a hard time sorting/separating by Main category > Sub category.</p> <p>Here is where I am so far with the getting of the main categories:</p> <pre><code> Protected Sub getFaqData(ByVal DocArray() As CMSWS.CMSDocumentRecord) Dim mainFaqCategoryItem As String = "" Dim mainCategoryList As New List(Of String) For Each Doc As CMSWS.CMSDocumentRecord In DocArray xml.LoadXml(Doc.Xml) Try mainFaqCategoryItem = CType(xml.SelectSingleNode("//Fields/Field[@name='FaqCategory']").InnerText, String) If Not mainCategoryList.Contains(mainFaqCategoryItem) Then mainCategoryList.Add(mainFaqCategoryItem) End If Catch ex As Exception Response.Write("ERROR getting the main category") End Try Next For Each item In mainCategoryList outputsubs(item, DocArray) Next End Sub </code></pre> <p>Here is the start of getting the sub categories and where I am stuck:</p> <pre><code> Protected Sub outputsubs(ByVal item As String, ByVal DocArray() As CMSWS.CMSDocumentRecord) Dim subFaqCategoryItem As String = "" Dim subcategoryList As New List(Of String) 'Add the main Category to the HTML output: lblFaq.Text = lblFaq.Text &amp; "&lt;h1&gt;" &amp; item &amp; "&lt;/h1&gt;" For Each Doc As CMSWS.CMSDocumentRecord In DocArray xml.LoadXml(Doc.Xml) Try 'If xml.SelectSingleNode("//Fields/Field[@name='FaqCategory']").InnerText = item Then subFaqCategoryItem = CType(xml.SelectSingleNode("//Fields/Field[@name='FaqCategory']").InnerText, String) If Not subcategoryList.Contains(subFaqCategoryItem) Then subcategoryList.Add(subFaqCategoryItem) End If 'End If Catch ex As Exception Response.Write("ERROR getting the main category") End Try Next For Each subItem In subcategoryList lblFaq.Text += "&lt;h2&gt;&lt;a name=""subCategory"" style=""text-decoration:none;""&gt;&lt;span class=""FAQPlusMinus""&gt; + &lt;/span&gt;" &amp; subItem &amp; "&lt;/a&gt;&lt;/h2&gt;" Next End Sub </code></pre> <p>My thinking is that I will need to set up for-each loops nested to about 3 levels to get this to work, but I can't get my brain around it. Especially since it isn't a single XML document. Which works to display the main categories</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload