Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6844101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:20:05+00:00 2026-05-27T00:20:05+00:00

My XML comes in like this: <Document type=ContentPage> <Fields> <Field name=FaqCategory type=dropdown title=Select Category:

  • 0

My XML comes in like this:

<Document type="ContentPage">
<Fields>
    <Field name="FaqCategory" type="dropdown" title="Select Category:" index="FaqCategory" list="\Lists\FaqCategory" required="true">
        Online Experience
    </Field>
    <Field name="FaqSubCategory" type="dropdown" title="Select Sub Category" list="\Lists\FaqSubCategory" required="true">
        Using the site
    </Field>
    <Field name="FaqQuestion" type="text" title="Enter FAQ Question:" required="true">
        How do I find articles on the site?
    </Field>
    <Field name="FaqAnswer" type="richtext" title="Enter FAQ Answer:" editorProfile="Advanced" required="true">
        Answer to: How do I find articles on the site?
    </Field>
</Fields>
<Placeholders />
<Indexes />

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.

Here is where I am so far with the getting of the main categories:

    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

Here is the start of getting the sub categories and where I am stuck:

    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 & "<h1>" & item & "</h1>"

    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 += "<h2><a name=""subCategory"" style=""text-decoration:none;""><span class=""FAQPlusMinus""> + </span>" & subItem & "</a></h2>"
    Next
End Sub

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:20:06+00:00Added an answer on May 27, 2026 at 12:20 am

    I found the solution with trial and error, not sure if anyone else will be dealing with a similar situation but here is how I got it to work:

    Protected Sub outputFaqData(ByVal DocArray() As CMSWS.CMSDocumentRecord)
    
        Dim mainFaqCategoryItem As String = ""
        Dim mainCategoryList As New List(Of String)
        Dim xmlDocText As New StringBuilder()
        xmlDocText.Append("<Documents>")
        For Each cmsDoc As CMSWS.CMSDocumentRecord In DocArray
            xmlDocText.Append(cmsDoc.Xml)
        Next
        xmlDocText.Append("</Documents>")
        Dim doc As New XmlDocument()
        doc.LoadXml(xmlDocText.ToString())
        Dim nav As XPathNavigator = doc.CreateNavigator()
        Dim exp As XPathExpression = nav.Compile("//Documents/Document/Fields")
        exp.AddSort("Field[@name='FaqCategory']", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Text)
        exp.AddSort("Field[@name='FaqSubCategory']", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Text)
        Dim leftNavHTML As New StringBuilder()
        Dim faqHTML As New StringBuilder()
        Dim currentCategoryName As String = ""
        Dim currentFaqSubCategory As String = ""
        Dim isFirstPass As Boolean = True
        For Each item As XPathNavigator In nav.Select(exp)
            Dim FaqCategory As String = item.SelectSingleNode("Field[@name='FaqCategory']").InnerXml
            Dim FaqSubCategory As String = item.SelectSingleNode("Field[@name='FaqSubCategory']").InnerXml
            Dim FaqQuestion As String = item.SelectSingleNode("Field[@name='FaqQuestion']").InnerXml
            Dim FaqAnswer As String = item.SelectSingleNode("Field[@name='FaqAnswer']").InnerXml
            Dim isNewFaqCategory As Boolean = False
            Dim isNewFaqSubCategory As Boolean = False
            If Not currentCategoryName.Equals(FaqCategory) Then
                isNewFaqCategory = True
            End If
            If Not currentFaqSubCategory.Equals(FaqSubCategory) Then
                isNewFaqSubCategory = True
            End If
            If Not isFirstPass And (isNewFaqSubCategory Or isNewFaqCategory) Then
                faqHTML.Append("</div>")
            End If
            If isNewFaqCategory Then
                currentCategoryName = FaqCategory
                If Not isFirstPass Then
                    faqHTML.Append("</div><div id=""alp_rightcolumn"">")
                End If
                leftNavHTML.Append("<h4 class='FaqCategory'>" & FaqCategory & "</h4>")
                faqHTML.Append("<h1 class='FaqCategory'>" & FaqCategory & "</h1>")
            End If
            If Not isFirstPass And (isNewFaqSubCategory Or isNewFaqCategory) Then
                faqHTML.Append("</div>")
            End If
            If isNewFaqSubCategory Then
                faqHTML.Append("<div class='FaqSubCategoryDiv'>")
            End If
            Dim QAID As String = Guid.NewGuid().ToString
            If isNewFaqSubCategory Then
                currentFaqSubCategory = FaqSubCategory
                leftNavHTML.Append("<div class='FaqSubCategory'><a href='#" & QAID & "'>" & FaqSubCategory & "</a></div>")
                'faqHTML.Append("<br/>:FIN")
                faqHTML.Append("<h2 class='FaqSubCategory'><a name='" & QAID & "'><span class='FAQPlusMinus'> + </span> " & FaqSubCategory & "</a></h2>")
            End If
            If isNewFaqSubCategory Then
                faqHTML.Append("<div class='QuestionsBox'>")
            End If
            faqHTML.Append("<a class='FAQQuestion' href='#' onClick=""showAnswer('" & QAID & "');return false;"">" & FaqQuestion & "<img src='/images/FAQ_Arrow.gif'/> </a>")
            faqHTML.Append("<div class='FAQAnswer " & QAID & "'>" & FaqAnswer & "</div>")
            isFirstPass = False
        Next
        faqHTML.Append("</div>")
        faqHTML.Append("</div>")
        litFAQLeftColumn.Text = leftNavHTML.ToString
        litFAQ.Text = faqHTML.ToString
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a XML file template like this that comes from some IC chips,
Suppose i have an xml document like this XML File: <document> <educationalsection> educational details
I have an xml document that looks like this. <?xml version=1.0?> <services> <service sn=1
I have an XML like the following: <documentation> This value must be <i>bigger</i> than
I'm needing to load an XML document into PHP that comes from an external
I have an xml that comes in two forms <root> <element1 req=mandatory/> <element2/> <element3/>
I'm generating some XML documents and when it comes to the address part I
The Rhino Mocks download comes with a Rhino.Mocks.xml file that apparently adds Intellisense for
I'm a newbie when it comes to properties, and I read that XML is
XML sample ( original link ): <records> <record index=1> <property name=Username>Sven</property> <property name=Domain>infinity2</property> <property

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.