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

  • Home
  • SEARCH
  • 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 8030347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:44:12+00:00 2026-06-05T00:44:12+00:00

I have an XML input as shown below: <?xml version=1.0 encoding=utf-8?> <Content> <section name=FileID/>

  • 0

I have an XML input as shown below:

<?xml version="1.0" encoding="utf-8"?>
 <Content>
    <section name="FileID"/>
    <FileID>109F2AEA-6D9C-4127-963A-9C71D4155C5D</FileID>
       <File Path="C:\test.config">
          <Tag TagName="configuration"/>
       </File>
 </Content>

When I do a recursive search of each node to identify the node with the name “FileID” using the following code line in PowerShell:

if($ConfigChildItem.Name -eq "FileID")
{
    ...
}

where $ConfigChildItem is getting populated with nodes from the XML in recursive to get searched.
By this I was expecting to get the Nodes with the name “FileID” like:

<FileID>109F2AEA-6D9C-4127-963A-9C71D4155C5D</FileID>

But it is getting out tags like:

<section name="FileID"/>

since those are having attribute “name” with the value “FileID”.
How can get only the tags with name “FileID” and not the kind of ones with attribute name as “name” and value of those attributes as “FileID”?

  • 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-06-05T00:44:14+00:00Added an answer on June 5, 2026 at 12:44 am

    One of the many ways to do it (using xpath):

    $xml = [XML] @'
    <?xml version="1.0" encoding="utf-8"?>
     <Content>
        <section name="FileID"/>
        <FileID>109F2AEA-6D9C-4127-963A-9C71D4155C5D</FileID>
           <File Path="C:\test.config">
              <Tag TagName="configuration"/>
           </File>
     </Content>
    '@
    
    $expression = "Content/FileID"
    $navigator = $xml.PSBase.CreateNavigator()
    $node = $navigator.Evaluate($expression)
    $node | Select OuterXml # or any other properties
    

    EDIT following your comment:

    $xml = [xml](Get-Content "c:\temp\test.xml")
    $xml.SelectSingleNode("//FileID")  | ?{ $_.InnerText -eq "109F2AEA-6D9C-4127-963A-9C71D4155C5D" } | %{ $_.InnerText = "blah" }
    $xml.Save("c:\temp\test.xml")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following input XML: <root age=1> <description>some text</description> <section> <item name=a> <uuid>1</uuid>
i have xml file that looks like this: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE pointList SYSTEM
I have XML that looks like the following: <?xml version=1.0 encoding=UTF-8 standalone=yes?> <ObjectList> <object
I have the following HTML code: <?xml version=1.0 encoding=utf-8 ?> <!DOCTYPE html PUBLIC -//W3C//DTD
<?xml version=1.0 encoding=utf-8?> <s:Application xmlns:fx=http://ns.adobe.com/mxml/2009 xmlns:s=library://ns.adobe.com/flex/spark xmlns:mx=library://ns.adobe.com/flex/mx width=1501 height=960 minWidth=955 minHeight=600> <fx:Declarations> <!-- Place
<To> <Id>SERVICE</Id> <Role>Commuter</Role> </To> <BPD> <OrgNo>234</OrgNo> </BPD> <BON>123</BON> I have this Input XML in
I have written xml file which contains html tags as element like <component> <input
I have this use case of an xml file with input like Input: <abc
This is my .xml file where I have used two scrollview,in Input Edittext and
I have a XML input which is obtained dynamically.How can i write the style

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.