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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:28:48+00:00 2026-05-27T15:28:48+00:00

I have the following xml structure : <?xml version=1.0 encoding=utf-8 ?> <nws> <url>http://cpa.hypotheses.org/feed</url> <url>http://news.ycombinator.com/rss</url>

  • 0

I have the following xml structure :

    <?xml version="1.0" encoding="utf-8" ?>
    <nws>
      <url>http://cpa.hypotheses.org/feed</url>
      <url>http://news.ycombinator.com/rss</url>
      <url>http://rss.slashdot.org/Slashdot/slashdot</url>
      <url>http://feeds.feedburner.com/hackaday/LgoM</url>
    </nws>

…And so on.

I wouldlike to remove the nth element. That’s it. All examples I’ve seen involve searching the node content using xmatch and I cannot search it because 1-it’s a complicated string and 2-I really don’t know the string I want to delete, but I do know the index.

I can read all the url nodes like this :

$.ajax({
type: 'GET',
url: 'conf.xml',
dataType: 'xml',
success: parseXml
});


$(xml).find("url").each(function() {
    $("#output").append($(this).text());
    // $("#output").append(": " + $(this).find("Title").text() + "<br />");
});

But I cannot seem to say “output only the second one”, let alone remove it.

One more thing. I understand that once I manipulated the XML DOM I have to write it back to the file using

echo $urlFile->asXML('myfile.xml');

But the process is somehow fuzzy (to What class does this “asXML” method belong to ? Is it even available in this context ? Do I have to load another library than just jquery.js ?)
I’m lost somewhere in the process ; Can somebody please post a rundown of the whole process ? ie

  1. read the file
  2. find, say the second node by the name of the node (not its content or attribute)
  3. delete it
  4. write back the modified representation of the DOM to the file

(ideally I’d like to be able to do some checks before writing back to the file, like empty lines, etc)

Even if the example is not functional, I just want to wrap my head around the concept.

  • 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-27T15:28:49+00:00Added an answer on May 27, 2026 at 3:28 pm

    OK, I solved half of the pb : I can now delete the nth node using its index, like this :

    $(document).ready(function() {
    
        $.ajax({
        type: 'GET',
        url: 'conf.xml',
        dataType: 'xml',
        success: parseXml
        });
    
        function parseXml(xml) {
        $(xml).find("url").eq(3).remove(); // <= The answer I was looking for
    
        $(xml).find("url").each(function(index) {
            $("#output").append($(this).text());
        });
        }
    });
    

    This outputs my list without the 3rd element. (but not as a DOM object). Still, Wohoo !

    Now how can I get it back (as a DOM object) in a php var to write it back to the file ? Or using ajax maybe ? I can read a file from ajax, but not write to it, I don’t know how to do that, anyone ever done this that could point me in the right direction ? (save JS-processed XML to an actual file ?)

    Regards, -ph

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

Sidebar

Related Questions

I want have the following output: <?xml version=1.0 encoding=UTF-8?> <structure:structuralDataRoot xmlns:register=http://www.test.ch/register/1 xmlns:structure=http://test.ch/structure/1 > <structure:tester>ZH</structure:tester>
I have the following XML structure: <?xml version=1.0 encoding=utf-8 standalone=yes?> <Root xmlns:xsi=My Program> <NotRoot
I have an loaded an XML document with the following structure: <?xml version=1.0 encoding=UTF-8
I have xml file whose structure is defined with following xsd: <?xml version=1.0 encoding=utf-8?>
I have the following simplified XML structure: <?xml version="1.0" encoding="UTF-8"?> <ExportData> <TransportHeader> <Timestamp>2011-01-16 06:00:33</Timestamp>
I have the following xml structure: <?xml version=1.0 encoding=utf-8 ?> <administrators> <administrator> <fullname>full name1</fullname>
Say I have this following XML structure: <?xml version=1.0 encoding=UTF-8?> <main> <parent> <child1>some value</child1>
I have the following XML structure: <?xml version=1.0 encoding=utf-8?> <xml> <root> <Item> <taxids> <string>330</string>
I have an xml document with the following structure: <?xml version=1.0 encoding=UTF-8?> <items> <item>
I have an XML file of the following structure: <?xml version=1.0 encoding=utf-8?> <root> <ArrayOfLocationDTO

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.