SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Location
    USA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to dynamically insert a comment in an xml file

    I have a simple task of adding a comment at the beginning of the line of xml file, where a specified latin letter is found.
    Now i have been doing this manually, but I'm pretty sure there must be a better way of doing this. To more clearly explain:

    existing line of code:
    <xs:pattern value="([X]|[x]|[\?]){1}"/>

    needs to be
    <!-- changed line --> <xs:pattern value="([X]|[x]|[\?]){1}"/>

    The comments have to be added to those lines in the file that contain the X in it, so how do i dynamically add a comment to at the beginning of those lines.

    I can only think of using PHP for this since I'm new to pretty much everthing else, but what do the experts say?

    Thanks

  2. #2
    SitePoint Zealot
    Join Date
    Apr 2005
    Location
    London
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could try using 'sed'. It doesn't have an idea about XML, but does it really need to know?

    also this is in the Java forum.. are you looking for a Java based solution?

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Location
    USA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's an xml file, so I figure java would be the way to go, somehow. Thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •