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 7417409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:41:50+00:00 2026-05-29T07:41:50+00:00

I have an XML document like this: <?xml version=’1.0′ encoding=’UTF-8′?> <GateDocument> <!– The document’s

  • 0

I have an XML document like this:

<?xml version='1.0' encoding='UTF-8'?>
<GateDocument>
<!-- The document's features-->
<GateDocumentFeatures>
<Feature>
  <Name className="java.lang.String">MimeType</Name>
  <Value className="java.lang.String">text/html</Value>
</Feature>
</GateDocumentFeatures>

<!-- The document content area with serialized nodes -->

<TextWithNodes><Node id="0" />astralis<Node id="8" /> <Node id="9" />ltd<Node id="12" />
<Node id="14" />{<Node id="15" />DOCUMENT<Node id="23" />}<Node id="24" /> <Node id="25" />{<Node id="26" />TYPE<Node id="30" />}<Node id="31" />EX-<Node id="34" />10<Node id="36" />.<Node id="37" />12<Node id="39" /> <Node id="40" />{<Node id="41" />SEQUENCE<Node id="49" />}<Node id="50" />3<Node id="51" /> <Node id="52" />{<Node id="53" />FILENAME<Node id="61" />}<Node id="62" />e<Node id="63" />300201<Node id="69" />_<Node id="70" />ex<Node id="72" />10<Node id="74" />-<Node id="75" />12<Node id="77" />.<Node id="78" />txt<Node id="81" /> <Node id="82" />{<Node id="83" />DESCRIPTION<Node id="94" />}<Node id="95" />
</TextWithNodes>

<Annotations>
.
.
.
.
.
</Annotations>

<Annotations Name="Original markups">
.
.
.
.
</Annotations>

</GateDocument>

I have loaded this XML in XMLDocument using vb.net/asp.net. I need data between Nodes with id > 16 and Id < 30 that is “}{TYPe}” Please note that It is not attribute’s value. It is data between nodes. I created following code but It is very slow.

   Dim sb As New StringBuilder()
            Dim document As New XPathDocument(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/gate_xml_output.xml"))
            Dim navigator As XPathNavigator = document.CreateNavigator()
            Dim iterator As XPathNodeIterator = navigator.Select("//TextWithNodes/node()[preceding-sibling::Node[@id=" & startNode & "] and following-sibling::Node[@id=" & endNode & "]]")


            While iterator.MoveNext()
                sb.Append(iterator.Current.Value & " ")
            End While

May be I need to modify following code:

XDocument doc = XDocument.Parse(@"<TextWithNodes>...</TextWithNodes");

string result = string.Join(" ",
    doc.Root
       .Nodes()
       .SkipWhile(n => n.NodeType != XmlNodeType.Element ||
                       (int)((XElement)n).Attribute("id") != 16)
       .TakeWhile(n => n.NodeType != XmlNodeType.Element ||
                       (int)((XElement)n).Attribute("id") != 30)
       .OfType<XText>());

// result == "pet DOCUMENT"

What I need to supply to XDocument.Parse.

Please suggest.

  • 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-29T07:41:50+00:00Added an answer on May 29, 2026 at 7:41 am

    I used the range 15 to 30

      XDocument xml = XDocument.Load("file.xml");
      var firstElement = xml.Descendants().Where(x => x.Name == "Node" && x.Attribute("id").Value=="15").FirstOrDefault();
      var lastElement = xml.Descendants().Where(x => x.Name == "Node" && x.Attribute("id").Value == "30").FirstOrDefault();
      var response = firstElement.NodesAfterSelf().Where(x => lastElement.NodesBeforeSelf().Contains(x));
    

    This returns the elements. You can get the contents with ToString()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml document like this: <?xml version=1.0 encoding=utf-8 ?> <demographics> <country id=1
So i have an XML document that looks like this: <?xml version=1.0 encoding=UTF-8?> <gesmes:Envelope
I have an xml document like this: <?xml version=1.0 encoding=UTF-8?> <foo:root xmlns:foo=http://abc.com# xmlns:bar=http://def.com xmlns:ex=http://ex.com>
I have an XML document with a basic structure like this: <?xml version=1.0 encoding=UTF-8
I have an xml document that looks something like this <?xml version=1.0 encoding=UTF-8?> <mapPoints>
I have an XML document something like ::: <?xml version=1.0 encoding=utf-8?> <?mso-application progid=Excel.Sheet?> <Workbook
I have an XML document from an external source. <?xml version=1.0 encoding=utf-8?> <ns0:Info xmlns:ns0=http://www.ZomboCorp.com/>
I have an xml document that looks like this <?xml version=1.0?> <XML> <VIDEO> <WIDTH>800</WIDTH>
I have a xml document like this : <Node1 attrib1=abc> <node1_1> <node1_1_1 attrib2 =
Hi I have an xml document like this <root> <cert id=1> </cert> <cert id=2>

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.